With frontendApiProxy enabled, the first API request after sign-in returns signed-out (client-uat-but-no-session-token)
Maintainer antworten meist innerhalb von 1 Tag
@ShivamJuyal24 arbeitet bereits daran.
Seit 14.11.2026.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- Ein halber Tag
- Anfängerfreundlichkeit
- 62/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- nextjs, nodejs, typescript
- Bereich
- authentication, backend
Rechercherichtung
Start in the backend package's AuthenticateContext: read usesSuffixedCookies() and tokenBelongsToInstance(), and compare the token issuer against originalFrontendApi and the proxy URL the issue describes. Reproduce with a non-document request carrying __client_uat and __session without a suffix, using a proxy-configured clerkMiddleware. Done when such a request resolves as signed in and the existing suffixed-cookie tests still pass.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Title: With frontendApiProxy enabled, the first API request after sign-in returns signed-out (client-uat-but-no-session-token)
Packages
@clerk/nextjs7.2.5 (@clerk/backend3.3.0)- The same code is in
@clerk/backend3.27.0 (latest at the time of writing) - Production instance, Next.js 16 App Router, deployed on Vercel
Setup
clerkMiddleware(handler, { frontendApiProxy: { enabled: true, path: "/__clerk" } })NEXT_PUBLIC_CLERK_PROXY_URL=https://<our-domain>/__clerk- The proxy is enabled in the Clerk dashboard with the same URL
- The publishable key's Frontend API is
clerk.<our-domain>
What happens
- Sign in with Google OAuth (via
/sso-callbackandAuthenticateWithRedirectCallback). - The app navigates client-side to a protected page, which calls
fetch("/api/projects"). - That request gets a 401: the middleware's
auth()returnsuserId: null. - A hard refresh fixes it: the document request goes through a handshake, and after that every request works.
It happens on every sign-in, in a fresh browser too.
Cookies on the failing request
__client_uat=1794509021
__client_uat_<suffix>=1794509017
__session=<JWT: iss="https://<our-domain>/__clerk", azp="https://<our-domain>", iat=1794509021>
(no __session_<suffix>)
Cause, from reading the source
AuthenticateContext.usesSuffixedCookies() returns true early when the plain session token does not belong to the instance:
if (session && !this.tokenBelongsToInstance(session)) {
return true;
}
tokenBelongsToInstance() compares the token's iss, without its scheme, against this.originalFrontendApi. That value comes from the publishable key (clerk.<our-domain>). With a proxy, the issuer is <our-domain>/__clerk, so the check fails for every token this instance issues.
The context then reads the suffixed cookies. Right after sign-in, __client_uat_<suffix> is set but __session_<suffix> is not, so the request resolves to client-uat-but-no-session-token. A non-document request can't run a handshake, so it is treated as signed out.
Expected
A token whose issuer is the configured proxy URL counts as belonging to the instance, and the plain cookies are used as they are without a proxy.
Possible fix
In tokenBelongsToInstance, also accept the proxy URL (this.proxyUrl without its scheme) as an issuer for this instance.
Workaround
Turn the proxy off.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 1.8k
- Forks
- 492
- Ø Merge
- 1 T. 7 Std.
- Gemergte PRs (30 T.)
- 357
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus clerk/javascript
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
clerk/javascript#10708 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Built-in reverification dialog lacks an accessible name (aria-dialog-name)Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
clerk/javascript#10548 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
clerk/javascript#10547 ·
Maintainer antworten meist innerhalb von 1 Tag
-
<SignIn />: first "Use email" click switches back to phone when `initialValues.phoneNumber` is setEvtl. vergeben @twicestruck hat das vor 20 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
clerk/javascript#10487 ·
Maintainer antworten meist innerhalb von 1 Tag
-
useLoadedIsomorphicClerk misses "ready" when a ClerkProvider remounts after clerk-js has loaded — <ClerkLoading> never resolvesEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
clerk/javascript#10462 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in clerk/javascript
Ähnliche Issues
-
Type/Improvement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
OpenNSW/nsw-srilanka#1259 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
oxc-project/tsrs#1010 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Fission-AI/OpenSpec#2260 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add: ESP 1 UKOffencheck:passed streams:add
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 64/100
Maintainer antworten meist innerhalb von 1 Tag
-
area:infra area:storage bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
THU-MAIC/OpenMAIC#2311 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag