v1.9.1: fix the SuperTokens login that signed you in and left you logged out - #14
Merged
Merged
Conversation
POST /auth/signinup answered status "OK", the client reported success, the URL went back to /, and the very next GET /api/me was a 401 - so the login screen came back with nothing wrong on it. SuperTokens picks the session's token transfer method at creation from the `st-auth-mode` request header, and defaults to "header" when it is absent (session/sessionRequestFunctions.js: "We default to header if we can't 'parse' it or if it's undefined"). The session came back in st-access-token / st-refresh-token response headers and no cookie was ever set. supertokens-web-js sends that header for you; v1.9.0 hand-rolled the calls without it. That is the one frontend-SDK responsibility hand-rolling inherited silently. Proved against a real core rather than from source. Same endpoint, both ways, and BOTH return 200 - which is why no layer reported anything: without st-auth-mode -> Set-Cookie: (none) st-access-token, st-refresh-token with st-auth-mode:cookie -> Set-Cookie: sAccessToken, sRefreshToken Also makes the failure impossible to ship again in silence: a sign-in the server calls OK that is followed by no session now says so on the login screen instead of returning a blank form. The absence of that message is the only reason v1.9.0 reached a production deploy. Guarded at both layers, and both confirmed by mutation - renaming the header fails the unit test and the smoke round trip. 698 vitest SQLite / 724 Postgres / 50 smoke. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the v1.9.0 regression reported in production: the GitHub button redirects to
/auth/callback/github?code=…and then lands back on the login page.What was happening
POST /auth/signinupansweredstatus: "OK". The client reported success, replaced the URL with/, and the very nextGET /api/mewas a 401 — so the login screen came back with no error on it, which is why it read as "the button does nothing".SuperTokens picks the session's token transfer method at creation time from the
st-auth-moderequest header, and defaults toheaderwhen it is absent —session/sessionRequestFunctions.js:So the session came back in
st-access-token/st-refresh-tokenresponse headers and no cookie was ever set.supertokens-web-jssends that header for you; v1.9.0 hand-rolled the three calls without it. That is the one frontend-SDK responsibility hand-rolling inherited silently — and the plan's own trade-off table listed "must write it" only against refresh, not against session transport.Proved against a real SuperTokens core rather than inferred from source. Same endpoint, both ways — and note both return 200, which is why no layer reported anything:
Set-Cookiest-auth-mode(v1.9.0)st-access-token,st-refresh-tokenst-auth-mode: cookie(this PR)sAccessToken,sRefreshTokenThe fix
st-auth-mode: cookieonPOST /auth/signinupand onPOST /auth/session/refresh. Cookies are right here because the app already relies on them end to end —credentials: 'include'everywhere, and the legacy JWT cookie works the same way.Testing
698 vitest (SQLite) / 724 (Postgres) / 50 smoke.
Guarded at both layers, both confirmed by mutation — renaming the header fails the unit test (
expected undefined to be 'cookie') and the smoke round trip (signinup must ask for cookie transport, got undefined). The new smoke check drives the exact v1.9.0 failure: signinup fulfilledOKwith no cookie, asserting the player is told rather than silently bounced.Note
AUTH_MODE=passport+ restart is the instant workaround if you need to log in before this ships — the client renders passport links in that mode and the passport routes are still registered.🤖 Generated with Claude Code