Solution skill
Infinite redirect loop in NextJS development environment
Complete solution
Shows how to fix infinite redirect loop in NextJS development environment. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Three distinct causes found in the thread: (1) a bug fixed by upgrading to @clerk/nextjs 4.21.13 (reporter). (2) The machine clock being out of sync: maintainer royanger explained to add debug:true to authMiddleware - a 'JWT issued at date claim (iat) is in the future (reason=token-not-active-yet)' message means sync the system clock/timezone with a time server; multiple reporters confirmed this fixed it. (3) A stale _clientuat cookie with a bad value of 0 (from a previous auth provider or switching subdomains) - clear cookies (reporter kachar).
Steps
- Three distinct causes found in the thread: (1) a bug fixed by upgrading to @clerk/nextjs 4.21.13 (reporter). (2) The machine clock being out of sync: maintainer royanger explained to add debug:true to authMiddleware - a 'JWT issued at date claim (iat) is in the future (reason=token-not-active-yet)' message means sync the system clock/timezone with a time server; multiple reporters confirmed this fixed it. (3) A stale _clientuat cookie with a bad value of 0 (from a previous auth provider or switching subdomains) - clear cookies (reporter kachar).
When to use
You are seeing this: Infinite redirect loop in the Next.js dev environment right after logging in, with @clerk/nextjs 4.x on YOUR_HOST. Use this skill when you run into "Infinite redirect loop in NextJS development environment".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: clerknextjs 4.21.13. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
In gh:clerk/javascript#1436 (https://github.com/clerk/javascript/issues/1436), the question was: Infinite redirect loop in the Next.js dev environment right after logging in, with @clerk/nextjs 4.x on YOUR_HOST. The verified resolution: Three distinct causes found in the thread: (1) a bug fixed by upgrading to @clerk/nextjs 4.21.13 (reporter). (2) The machine clock being out of sync: maintainer royanger explained to add debug:true to authMiddleware - a 'JWT issued at date claim (iat) is in the future (reason=token-not-active-yet)' message means sync the system clock/timezone with a time server; multiple reporters confirmed this fixed it.
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_DFQY4davxmalBD7v8XFAGQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Infinite redirect loop in NextJS development environment <span>— Vectle</span></a>