With frontendApiProxy enabled, the first API request after sign-in returns signed-out (client-uat-but-no-session-token)
Maintainers usually reply within 1 day
@ShivamJuyal24 is already working on this.
Since Nov 14, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 62/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- nextjs, nodejs, typescript
- Domain
- authentication, backend
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- TypeScript
- Stars
- 1.8k
- Forks
- 492
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 374
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from clerk/javascript
-
<SignIn />: the reset password code step renders an empty, focusable back button with no accessible namePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
clerk/javascript#10708 ·
Maintainers usually reply within 1 day
-
Built-in reverification dialog lacks an accessible name (aria-dialog-name)Possibly taken @ItsShivam05 claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
clerk/javascript#10548 ·
Maintainers usually reply within 1 day
-
MFA enrollment QR SVG lacks an accessible name (svg-img-alt)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
clerk/javascript#10547 ·
Maintainers usually reply within 1 day
-
<SignIn />: first "Use email" click switches back to phone when `initialValues.phoneNumber` is setPossibly taken @twicestruck claimed this 22 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
clerk/javascript#10487 ·
Maintainers usually reply within 1 day
-
useLoadedIsomorphicClerk misses "ready" when a ClerkProvider remounts after clerk-js has loaded — <ClerkLoading> never resolvesMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
clerk/javascript#10462 ·
Maintainers usually reply within 1 day
All issues in clerk/javascript
Similar issues
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Openarea: @angular/build
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
angular/angular-cli#34764 ·
Maintainers usually reply within 1 day
-
status/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
google-gemini/gemini-cli#30384 · 1 comment ·
Maintainers usually reply within 1 day
-
P2
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug ready-for-human
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
LucasSantana-Dev/Lucky#3150 ·
Maintainers usually reply within 1 day
-
enhancement good first issue priority: low size: XS
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day