Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I avoid 401 error with useFetch and http basic auth, when SWR enabled #548

Open
lionel-addvanto opened this issue Nov 13, 2024 · 1 comment
Labels
question Further information is requested

Comments

@lionel-addvanto
Copy link

Hello, I have the newest Nuxt (v3.14.159) and nuxt-security (v2.0.0) packages .
When I call useFetch to a server route, in a page, where SWR is enabled, I get a 401 because of the http basic auth. When I manually include the headers in the request it works, but what is the Nuxt/nuxt-security intended way to do this?

Thank you and kind regards

@lionel-addvanto lionel-addvanto added the question Further information is requested label Nov 13, 2024
@Baroshem
Copy link
Collaborator

Baroshem commented Nov 14, 2024

Hey there,

The main intention behind Basic Auth in this module is to block accessing certain page/subpages but it also works for all server endpoints which does not render any route.

Have you maybe tried excluding this server route in exclude option? https://nuxt-security.vercel.app/documentation/middleware/basic-auth#exclude

There is also an issue for route based Basic Auth but it was not implemented yet - #443. Maybe you would be interested in contributing? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants