-
Notifications
You must be signed in to change notification settings - Fork 305
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
Infinite redirect loop in NextJS development environment #1436
Comments
Hello @Aayushpatil77 and thank you for opening this issue. |
Using Next.js and getting an infinite redirect. But when we refresh the page again, it will work as expected. GitHub repo example->https://github.com/adarsh-gupta101/Next-full-stack-editor |
@dimkl |
Had sort of the same issue. It works fine on localhost, but when I try to proxy (e.g. using ngrok) the browser gets stuck in an infinite loop. In my case, React does not display any error message. I tried to run the debugger in Chrome; found this line to be the "culprit": Why would my page suddenly have an empty fragment? I would expect that it is added in the call itself e.g. - window.location.href = window.location.href;
+ window.location.href = window.location.href + "#"; |
This was with version |
I got this error after switching auth providers to Clerk, I got it to work by clearing my old cookies. |
I got the same problem. Fresh install of T3, installed clerk, followed quick start docs, first npm run dev and i got this error. Tried everything. Skewing time updating, checked keys. It doesn't work |
I am using "@clerk/nextjs": "^4.23.2" this version and still getting the error... If anyone knows how to fix it please do let me know |
On my windows PC, syncing with the time server solved the issue. It might occur again, but I am good for now |
Yeah it also worked for me |
I am facing the same issue as of now. It was working fine the day before i was developing the app. when i ran the Next app again the next day, it's showing the infinite loop error. Is their any particular reason?? |
Clerk needs your system clock to be in sync with your current timezone. I synced my system timezone correctly. The clerk is working fine. |
Yeah that was the problem |
Tried syncing my time, still the same issue |
If you are experiencing this in NextJS, please add If you see an error like the one below, then it is indicating your clock is out of sync.
|
When I try clearing the cookies it works for me, but after saving a few changes to my code, it doesn't work anymoreGitHub Repo --> https://github.com/creative-tutorials/resubase |
Thanks for the tip, it shows much clearer information now, the state for isSignedIn seems to be treated as false, with a JWT message |
This is confirming that your clock is out of sync and in the future. Syncing your clock with a time server should resolve this error. |
Thank you very much, it turns out that toggling "Set time automatically" and "Set time zone automatically", with synchronizing the time, and properly setting my time zone did the trick. |
Does anybody encounter it on production app? where end users doesn't sync with time server from windows settings? (Mine also fixed with time server sync) |
Yikes, you're definitely right about that, there has to be like a workaround around this. |
I am using "@clerk/nextjs": "^4.23.2". I have changed the time and time zone and I still getting the same error ... Does anyone have a solutions? |
We've noticed. that certain users have bad cookie values which causes the infinite loop. The cookie name is Once we clear this cookie the redirect loops are gone. Our observation of this cookie is that it gets a bad value when we switch between the subdomains of our app - Production / Staging. |
I didn't get this bad value, All I needed was to change the time zone. Thanks for sharing by the way |
Which OS are you using If I may ask @emLuc86dev |
I"m using Windows 11. I changed my time and time zone. I cleared the cache
and cookies and I'm still getting the same error. Then I tried another web
browser and still the same...
Thanks for your time
El dom, 20 de ago de 2023 1:49 p. m., Timi ***@***.***>
escribió:
… I am using ***@***.***/nextjs": "^4.23.2". I have changed the time and time
zone and I still getting the same error ... Does anyone have a solutions?
Which OS are you using If I may ask?
—
Reply to this email directly, view it on GitHub
<#1436 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUXR5LLQAMTKQI4F4D5HM43XWJE2DANCNFSM6AAAAAAZYYYU6Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
We are experiencing the exact same error since releasing our production environment. The issue might be tied to the We have the following scenario:
This is the cookie we see on main:
This is what we see on develop:
Once one has visited the main site with their browser and switches to develop to test something, the site is trapped in an infinite loop with the error referring to the said cookie, ie.
We have to painfull clear the cookies, refresh everything and refrain from accessing the live site in the same session. It never occurs on (Node v18.17.0, @clerk/nextjs v4.29.3, in Docker) |
I just ran into the same issue after updating my node to v.21. I resolved the issue by downgrading node to v.18 and updating nextjs to v.14.1.0. Hope this might help someone! |
This will help a lot. Thanks! But I want to know who else is still having this issue. I'm on node v.20.10.0 and I haven't noticed these issues for a long time, it comes back yes, but when I sync my time, I don't notice it again. The issue only comes back whenever I run into a low battery on my laptop. |
I'm running into this on node v21.6.1 |
Try syncing your clock please |
We are also having this issue. Still have no clue how to fix it. |
This is due to clerk not supporting multiple instances on the same
host/domain name. I've asked clerk to call it out in the docs to
avoid confusion. They have a future feature planned that would support
instances across subdomain. Use another hostname and you won't hit the
infinite redirect.
…On Wed, Jan 31, 2024, 1:39 PM Rey ***@***.***> wrote:
I just ran into the same issue after updating my node to v.21. I resolved
the issue by downgrading node to v.18 and updating nextjs to v.14.1.0. Hope
this might help someone!
This will help a lot. Thanks!
But I want to know who else is still having this issue. I'm on node
v.20.10.0 and I haven't noticed these issues for a long time, it comes back
yes, but when I sync my time, I don't notice it again. The issue only comes
back whenever I run into a low battery on my laptop.
We are also having this issue. Still have no clue how to fix it.
—
Reply to this email directly, view it on GitHub
<#1436 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAG5UFXJ6CHKZPPCU2GUKDYRKMWDAVCNFSM6AAAAAAZYYYU6SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJZHAYDKNRWG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@jameslporter yes I just figured out it must be something like that. I was running prod on mydomain.com and a staging instance on a subdomain, staging.mydomain.com. This caused the infinite loop. I found out that if I cleared my cookies etc. in Chrome and then viewed the subdomain, it would work (at least for a while), but once I viewed the prod instance things would be screwed up again. Great to hear there is future work planned to support this across subdomains; would rather not have to pay for extra domains just to support a staging environment (unless that's a best practice for some reason etc.) |
For me upgrading to |
Not found! |
It happened only in development or even the production? |
It only helped for the initial page load but same issue after I refreshed. I have figured out the final fix now. Seem to be a Nextjs Issue. Upgrading to 14.1.3 solved the issue eventually. vercel/next.js#55648 |
Mainly
Mainly everyone should just upgrade to Next.js |
Yes, upgrading my Next.js ('^14.2.1') worked for me. Just do |
Same issue here. @stx-chris did you figure out a solution? Was it solved by updating to the latest packages? |
Hi guys, I figured out that the issue is related to the local storage and session's keys. When I delete them it works as expected. I guess this happens when the authentication failed. This is my only for my case. |
I got into redirect loop with these packages
|
@hieutrluu Could you please open a new issue or reach out to |
I found a rather dumb reason why I was being infinitly redirected in my end. In the middleware.ts setup, I had my RouteMatcher configured like so:
The problem was that the createRouteMatcher method was configured to redirect every path starting with "/", which Im assuming included the /sign-up page and created the loop. Changing the line to (I added the wildcard cause I wanted to make every route private, seems I might have to find another way...) |
Everyone has different ways on how to solve this issue, mainly I'd just upgrade all my packages to latest, and make sure my date-and-time are correct |
I faced the redirect issue due to middleware. Make sure, you include the sign in/sign up path in public path routes. Next, redirect won't happen anymore.
|
On my Windows machine, I turned off set time zone automatically and set time automatically and it worked...!!! |
So my users will need to sync their clock to the timezone or it's just happening for development? |
Only in development. If your users have a misconfigured clock chances are that they are having problems accessing all types of web pages.
…________________________________
From: Greg Wozniak ***@***.***>
Sent: Thursday, December 12, 2024 12:28:44 PM
To: clerk/javascript ***@***.***>
Cc: Vinicius Pinho ***@***.***>; Comment ***@***.***>
Subject: Re: [clerk/javascript] Infinite redirect loop in NextJS development environment (Issue #1436)
So my users will need to sync their clock to the timezone or it's just happening for development?
—
Reply to this email directly, view it on GitHub<#1436 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AXFVS2LBV7K5TSYE2QE34GL2FGTSZAVCNFSM6AAAAAAZYYYU6SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMZZGI4DMOJXGY>.
You are receiving this because you commented.Message ID: ***@***.***>
|
im getting the same error again with "next": "15.1.2" and "@clerk/nextjs": "^6.8.1" |
I am locking this conversation now. If you are having issues with Clerk, please reach out to our support and one of our dedicated staff will help get your issue resolved. I don't want anyone to end up posting a problem here expecting help, and it never gets answered, as our support team does not actively monitor closed github discussions. |
Description
I'm getting this error constantly after logging into an account.
This is development environment and running on localhost
Package + Version
@clerk/clerk-js
@clerk/clerk-react
@clerk/nextjs
@clerk/remix
@clerk/types
@clerk/themes
@clerk/localizations
@clerk/clerk-expo
@clerk/backend
@clerk/clerk-sdk-node
@clerk/shared
@clerk/fastify
@clerk/chrome-extension
gatsby-plugin-clerk
build/tooling/chore
The text was updated successfully, but these errors were encountered: