-
Notifications
You must be signed in to change notification settings - Fork 913
Module always adds Authorization header #1512
-
If I add tokenRequired: true to the config it will always try to send a token, even if there is none this will result in a 401 error from the backend as it will receive Authorization: Token undefined. This breaks endpoints that don't require authorization.
If I change this to tokenRequired: false, it never sends a token, which breaks endpoints that do require a token. Even if I try to call this with axios and set the axios header manually, this module overrides it.
I found documentation that said I configure the tokens to not be global but there's no explanation of how I can set a component to require a token or not.
Because of this behavior, I cannot make axios calls (even if I manually set the header) because nuxt-auth overrides all of my API calls.
Is there anyway that I can configure this to properly allow for protected and public endpoints?
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 4
Replies: 1 comment
-
I was using token: { global: true } and this added Authorization header to every request.
What finally worked for me was that I created a new axios instance using axios.create() for requests that didn't require authorization.
Beta Was this translation helpful? Give feedback.