-
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: Authentication flow state #86
Comments
Hey @prathmesh-pandya did you set up the API routes as specified in the docs https://kinde.com/docs/developer-tools/nextjs-sdk/#set-up-kinde-auth-route-handlers ? |
Also getting 500 issue on
|
I have the same error with the middleware. If you try to change the matchers, it is working for me. |
Same here |
How do you recommend if my matcher looks like this:
|
I have some minimum reproducible example, you can find that here: |
In @iyansr's case it seems the issue was using a subdomain for the post login redirect url
so the auth flow was starting on a naked He kindly shared his solution in the community Thought I would share in case it helps others |
Hi @DaveOrDead thank for share |
Hi..!! I am receiving the following TypeScript error: In Auth Route Handlers import {handleAuth} from "@kinde-oss/kinde-auth-nextjs/server"; export const GET = handleAuth(); Are there any specific TypeScript configurations..? |
@naz-i-ya can I ask which version of the SDK you're using please? |
|
@naz-i-ya Can you upgrade to 2.1.7 and try again? |
After the upgrade, the authentication process seems to be working fine; however, upon redirecting to the dashboard page, I encounter the following Error: This method must be invoked in a Node.js environment My project is utilizing Node.js version 18.17.1. |
@naz-i-ya Apologies, I missed your response, are you able to give me a reproduction ? |
Any news about this issue ? This is still a problem "next": "14.1.3" w/ app router
|
@nip10 I'm after some reproduction details. Can you help? What browser and OS do you see the issue? |
I'm trying to migrate a nextjs project from another auth provider to Kinde, but it's been a couple of days and I can't get this to work. Followed these docs. OS macOS 13.4 PS: I have another project using Kinde, also with NextJS and app router, but using sdk v1 and working fine |
Getting the exact same error, did you manage to figure out what is causing this? @nip10 Some info about our app Nextjs app router v14.1.3 The interesting thing in my case is that it only happens when trying to login from a mobile browser. |
@VaggelisKa I haven't, unfortunately. I spent some time debugging and trying different versions, middleware, etc, but this project was time sensitive so I ended up going in another direction. |
Apologies for the delay. Unfortunately, I wasn't able to resolve the issue, so I decided to switch to NextAuth. |
Thank you, The mobile browser aspect is really useful here, I have been unable to reproduce this issue locally. I will look at seeing what could cause the problem on iPhone. |
Hi, I was having this same error: I was getting it only in preview environments on Vercel. I am using a custom domain. I had KINDE_COOKIE_DOMAIN set, because I am using subdomains. Turns out that this should not be set for Vercel's preview environments. So I changed it to only be set for "preview on dev", which is my dev env on Vercel. Previously it was affecting all preview environments. Update: I also had some confusion with Vercel's Branch URLs vs Preview URLs. I'm using the script to add Vercel's URLs to Kinde's authorized URLs. I can either use the VERCEL_BRANCH_URL or the VERCEL_URL, I haven't found a way to use both. Make sure when testing, you know which one you're using. The Kinde docs use VERCEL_URL, but Vercel's Github comments use the VERCEL_BRANCH_URL. Info: https://kinde.com/docs/developer-tools/nextjs-sdk/#working-with-preview-urls In addition, the |
Hi, I also have the same problem when I try to log in. semper next js app on vercel. It also happens that when I log in and refresh the page, things come out of the login if you had never logged in. in fact when I checkout it tells me user not authenticated even if I'm logged in, but if I refresh it tells me log in immediately. locally everything works perfectly {"error":"Authentication flow: Received: 9d3d9c465029931219b20ee42e2d | Expected: State not found"} |
Same happening with me, in local machine it works and when I deployed my application, also setup .env file but failed |
I have no idea how to fix it. I tried asking kinde support |
Hey guys, sorry for letting this issue hang. Hopefully, I'll be able to shed some light on what the error means and what we're doing to help with the DX in the future. The fix
ExplanationThe
Let's say you set Then if you start the auth flow from a Vercel preview domain The error happens because when we start the auth flow, we set a cookie You are redirected to the wrong domain because What we'll do to help fix
More info can be found here: |
@prathmesh-pandya I was getting the same error. Figured that it was because there was /login and /register routes in my project. |
I had the impression that wrapping the links to |
@maxbraeutigam This is indeed a common issue, however using our |
Hi @DanielRivers, thanks for the clarification. Being honest, I also dropped the env var |
Hi everyone! Did anyone fixed the problem? My case: when the user logs in I forward him/her to /auth-callback to some additional stuff for specific condition. Basically, I use there the router of NextJS. Maybe the problem is because of that, too? Or maybe because I don't return the user back to the origin but forward to the /auth-callback? |
Prerequisites
Describe the issue
When click on register link or login link it throw me HTTP 500 error code and the url which i redirect by clicking the login link is http://localhost:3000/api/auth/register?
i have app router and i have write the code for login and register link in page.js of home or root
version of next js "next": "^13.5.6",
version of kinde "@kinde-oss/kinde-auth-nextjs": "^2.0.1",
node version 16.20.0
Library URL
https://github.com/kinde-oss/kinde-auth-nextjs
Library version
2.0.1
Operating system(s)
Other Linux
Operating system version(s)
Linux mint 20 Cinnamon ,Cinnamon version 4.6.6
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: