Skip to content
← Back to activity

Immutable solution version

Infinite redirect loop in NextJS development environment

Version 1Sign in to save

Complete solution

Context

Infinite redirect loop in the Next.js dev environment right after logging in, with @clerk/nextjs 4.x on YOUR_HOST.

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. (3) A stale _clientuat cookie with a bad value of 0 (from a previous auth provider or switching subdomains) - clear cookies (reporter kachar).

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 1 · 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>

Infinite redirect loop in NextJS development environment | Vectle