Cannot change auth endpoints in custom plugin #1517
Replies: 4 comments
-
I am having this problem too @NMFES, did you find a solution? |
Beta Was this translation helpful? Give feedback.
-
@elC0mpa |
Beta Was this translation helpful? Give feedback.
-
Yeah, in my project I've needed to be able to set endpoints, based on some ajax/axios results. After going trough like a dozen variants I've ended up using this kinda dumb, but working approach:
So I just fetch some data from API and then look at incoming requests URL and override it and add prefix. It's a really dumb solution, but for me it's the only one that works for this module. |
Beta Was this translation helpful? Give feedback.
-
thanks @disjointed I will try this later and let you know if this was useful for me |
Beta Was this translation helpful? Give feedback.
-
Version
5
Reproduction link
-
Steps to reproduce
nuxt.config.js
plugins/auth.js
If we try to log in - it works correctly. But once we have logged in and trying to refresh the page - Auth module tries to query default route /api/auth/user instead of /auth/user. I have to use this plugin because I need to pass current language (locale) as part of url (/lang/auth/user). Since we detect current language dynamically - we cannot hardcode it in nuxt config.
What is expected ?
Auth module should use the overridden routes from the plugin
What is actually happening?
It seems that Auth module queries fetchUser before plugins/auth.js is applied. Because once the page in fully loaded/mounted then other routes works correctly (at least /auth/login)
Beta Was this translation helpful? Give feedback.
All reactions