Middleware on the client side?

Is it possible to make the middleware run on the client side? I need it to check authentication towards another service.
6 Replies
Fabian B.
Fabian B.2y ago
Sure! You can add a middleware like usual https://nuxt.com/docs/guide/directory-structure/middleware and then just ask for if (process.client)
Nuxt
middleware/
Nuxt provides middleware to run code before navigating to a particular route.
Fabian B.
Fabian B.2y ago
But that’s not going to work when you’re in SSR mode I suppose So the question is why you only want to check authentication on the client. This will likely cause hydration issues.
Attacler/Bart
Attacler/BartOP2y ago
this is because im using a cms seperated from the nuxt app the access_token/refresh_token (or auth cookies) are also set on the cms domain and not on the nuxt domain
Fabian B.
Fabian B.2y ago
@Attacler/Bart Okay, check out if the solution I described works for you
Attacler/Bart
Attacler/BartOP2y ago
Will let you know, thanks so far! it works, thanks 🙂
Fabian B.
Fabian B.2y ago
Nice! Glad I could helped
Want results from more Discord servers?
Add your server