DEV Community

Discussion on: How to make nuxt auth working with JWT - a definitive guide

Collapse
 
ohidere profile image
ohidere

Hi MrNaif

I have a question I really need help with. I thought you would be the one able to help me as you created this amazing plugin.

When trying to access a page with auth middleware, everything works correctly. The problem is, though, that the application asynchronously loads and sees if the token is valid.
This causes 2 redirects that don't look very good for the user experience. How can I make it so that the token gets check SYNCHRONOUSLY and nothing is being shown on the page, and THEN perform redirects whenever the user is not authenticated?

Please see a GIF of the issue here:
i.imgur.com/ZSx5ByF.gif

(PS: Page not found notification is because I haven't defined the login route yet.)

Collapse
 
mrnaif2018 profile image
MrNaif2018

Hello! I think that for the best UX redirects should be done server side, via a middleware. Maybe try adding a middleware which checks token, and redirects based on that. Also those redirects look a little bit like hydration issues, check if you have those.

Collapse
 
ohidere profile image
ohidere

Thanks for your reply!
Do you mind giving out your contact details? I don't really know what you mean.

There'll be a little reward too ^^

Thread Thread
 
mrnaif2018 profile image
MrNaif2018

Sure, as long as it is something simple (:
Contact me in telegram(@MrNaif_bel)