-
Notifications
You must be signed in to change notification settings - Fork 25
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
Bug: /api/auth/setup
is failing with 401 Unauthorized
#170
Comments
I just realised that this is Sounds like a bug in the For reference, this is the problematic code const { user } = useKindeBrowserClient(); IIUC that's how I'm meant to check if a user is logged in or not, and hence there should be no call to |
This is current intended behaviour. Due to security measures the access token cookie is not readable by javascript so the browser knows nothing about the user. This The 401 happens when the user is not signed in as no token is present it doesn't have access to the route. This is something we want to improve in the future. |
I see thank you! @DanielRivers should we handle the request rejection and swallow it then to avoid spamming the console? If it's intended behaviour, there's a low-hanging fix to wrap it in a try/catch, and swallow the 401 errors? If it's any other status code we can rethrow. Either way I'll leave it with you and the team 🙂 |
Sadly, 401 errors cannot be omitted from the console. They are always outputted there is no way to prevent this. |
TIL. I guess you'd have to return 200 No worries then thanks for looking into this! |
I totally agree with @AntoLepejian , i think this could be handled better, or at least being well documented. In my team, we spent a considerable time figuring out this wasnt an error on our side. Please improve this behavior, to allow us to really handle unauthorized states when they are really intended... |
Thanks for the feedback here, this is under discussion internally on improved flows here, care has to be taken as this could result in a breaking change. |
Yep, I'm confused about this error, because this case is safe when local, but when deployed, the bug is there and I can't find a solution yet, is there a solution? |
Prerequisites
Describe the issue
Following the NextJS guide, I constantly see the following error in my console
This setup
fetch
call in this effect is always failing with401
error.The response just says "Login with Kinde".
At the moment it appears to be a red herring since I'm able to login anyways, but thought i'd report, since either the guide is missing a step, there's a bug with the SDK or I'm doing something wrong.
Thanks!
Library URL
https://github.com/kinde-oss/kinde-auth-nextjs
Library version
^2.2.10
Operating system(s)
macOS
Operating system version(s)
Sonoma 14.5
Further environment details
No response
Reproducible test case URL
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: