Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Route Problem


I'm using Mobx as state management
When I Refresh the page it goes back to the login page and then after checking the token with the server to log in the user then redirect to the dashboard
each time I refresh the page
My Route

return (
<>
<ToastContainer position='bottom-right' hideProgressBar />
<Switch>
{!userStore.isLogedIn ? (
<>
<Route>
<AuthPage />
</Route>
<Route path='/error' component={ErrorsPage} />
<Route path='/logout' component={Logout} />
</>
) : (
<>
<MasterLayout>
<PrivateRoutes />
</MasterLayout>
</>
)}
</Switch>
<MasterInit />
</>
)


Private Route

return (
<Suspense fallback={<FallbackView />}>
<Switch>
<Route path='/dashboard' component={DashboardWrapper} />
<Route path='/builder' component={BuilderPageWrapper} />
<Route path='/menu-test' component={MenuTestPage} />
<Route path='/master/item/category' component={ItemCategory} />
<Redirect from='/auth' to='/dashboard' />
<Redirect exact from='/' to='/dashboard' />
<Redirect to='error/404' />
</Switch>
</Suspense>
)


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (5)


I Check Your demo 1 of react also without Mobx the problem is still not solved



Hi Arifullah!

Sorry, looks like something broke since the last update.
I already created a task for this bug, we will take a look at this and provide a fix as soon as possible.



This issue is fixed in Metronic v8.0.35 release.



Hi The problem still exists after updating to v 34
I'm not using your models and redux I use Mobx

the above code is the same as yours but I only changed is authorized to isLogedIn from my store
when I refresh the page it goes to Auth page then redirect to the dashboard

this route when I refresh



Thanks



It is a bug, it happens because accessTokne is undefined.
The name in files Registration.tsx and Login.tsx doesn't match the actual name from the API.

We will include a fix in the upcoming Metronic v8.0.34 release.

Now as a temporary solution you can update the following files:
1)src/app/modules/auth/models/AuthModel.ts, replace accessToken property with access_token.
2)Update src/app/modules/auth/components/Registration.tsx and src/app/modules/auth/components/Login.tsx, in onSubmit function accessToken variable must be access_token as well.


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(