K
Kinde2w ago
Lump

Error: State not found

I deployed the application on Vercel and when I try to log in, I have this error and redirection to this site. Before that on my localhost dev server no errors occurred, the application and kinde worked perfectly. Here are the changes I made before deploying to vecel: By the way, here is the vercel deployment link: https://blog-marshal-three.vercel.app By the way x2 ,here is github repository of my app: https://github.com/nikitodeon/BlogMarshal-deploy.git Env variables in project vercel settings : KINDE_SITE_URL=https://blog-marshal-three.vercel.app KINDE_POST_LOGIN_REDIRECT_URL=https://blog-marshal-three.vercel.app/api/auth/creation KINDE_POST_LOGOUT_REDIRECT_URL=https://blog-marshal-three.vercel.app In my app details on kinde.com: Allowed callback URLs http://localhost:3000/api/auth/kinde_callback https://blog-marshal-three.vercel.app/api/auth/kinde_callback Allowed logout redirect URLs http://localhost:3000 https://blog-marshal-three.vercel.app When i try to login it redirects me to: https://blog-marshal-three.vercel.app/api/auth/kinde_callback?code=tU7LFHr_7cL2hmSQw3U_lNuAluy02twcIkaUwSwXN_I.OkdL2yrLafLoZqoKF-aJUHG7txTJHFkV8SxFWUMxLcw&scope=openid%20profile%20email%20offline&state=613e0bd69bc958ef6f6ca4a348d6 And i see this error json on my screen: {"error":"Error: State not found.\nTo resolve this error please visit our docs https://docs.kinde.com/developer-tools/sdks/backend/nextjs-sdk/#state-not-found-errorAuthentication flow: Received: 613e0bd69bc958ef6f6ca4a348d6 | Expected: State not found"}
Create Next App
Generated by create next app
GitHub
GitHub - nikitodeon/BlogMarshal-deploy
Contribute to nikitodeon/BlogMarshal-deploy development by creating an account on GitHub.
7 Replies
CB_Kinde
CB_Kinde2w ago
Hi @Lump we just released a new version of this doc today. Can you check you've done all the steps and let us know if you are still running into issues. https://docs.kinde.com/developer-tools/guides/deploy-on-vercel/
Kinde docs
Deploy an app on Vercel
Our developer tools provide everything you need to get started with Kinde.
Lump
LumpOP2w ago
Still have issues. Application details on kinde.com Callback URLs Application homepage URI https://blog-marshal-three.vercel.app The homepage link to your application. E.g. https://app.yourapp.com. Opens on logo-click and for other back link actions. Application login URI https://blog-marshal-three.vercel.app The default login route for resolving session issues. Allows users to redirect back to the application sign-in page via the /auth endpoint. E.g. https://app.yourapp.com/api/auth/login Allowed callback URLs https://blog-marshal-three.vercel.app/api/auth/kinde_callback These are the redirect URIs where the user can be sent after authenticating. Add each URL on a new line. Allowed logout redirect URLs https://blog-marshal-three.vercel.app These are the URLs where the user can be sent after signing out. Add each URL on a new line. in vercel KINDE_POST_LOGIN_REDIRECT_URL = https://blog-marshal-three.vercel.app/api/auth/creation KINDE_POST_LOGOUT_REDIRECT_URL = https://blog-marshal-three.vercel.app KINDE_SITE_URL= https://blog-marshal-three.vercel.app KINDE_CLIENT_ID same KINDE_ISSUER_URL same KINDE_ISSUER_URL same same redirect and error when sign in (in development all was ok) https://blog-marshal-three.vercel.app/api/auth/kinde_callback {"error":"Error: State not found.\nTo resolve this error please visit our docs https://docs.kinde.com/developer-tools/sdks/backend/nextjs-sdk/#state-not-found-errorAuthentication flow: Received: dc05a229d1bd8aa8201ab4921c30 | Expected: State not found"}
Create Next App
Generated by create next app
Yoshify
Yoshify2w ago
Hi @Lump - Do you have Vercel Deployment Protection enabled by any chance? This can intercept the Kinde callback and cause the State cookie to not be set.
Lump
LumpOP2w ago
@Yoshify Password protection was disabled, and now i disabled vercel authentication too, didn't help
Yoshify
Yoshify2w ago
May I attempt to create an account on your webpage to attempt to debug the State cookie?
Lump
LumpOP2w ago
Yes
Yoshify
Yoshify2w ago
Hi @Lump I've done some testing with my account on your website and there appears to be an infinite redirect loop causing this error. The initial response from Kinde correctly has the state cookie but because of the infinite redirect, it never has an opportunity to be saved to storage. After login/registration, the redirect loop appears to occur at /api/auth/creation which redirects to /dashboard which redirects to /api/auth/login then repeats continuously until ERR_TOO_MANY_REDIRECTS is thrown. I believe resolving this redirect loop should fix your state error.

Did you find this page helpful?