Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Module always adds Authorization header #1512

Unanswered
aaronsnig501 asked this question in Q&A
Discussion options

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?

You must be logged in to vote

Replies: 1 comment

Comment options

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.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Converted from issue

This discussion was converted from issue #1314 on January 20, 2022 10:38.

AltStyle によって変換されたページ (->オリジナル) /