Repository navigation
Sign out to /login, not a cross-host hop - #385
Merged
Merged
Conversation
The form POST 303'd to /, which the app host 301s to nemar.org once the cookie is cleared. CSP form-action 'self' blocks that cross-origin hop in Chrome, so the session ended but the page never moved. Add SIGNED_OUT_PATH (/login, an app route) and a host test pinning it. Unit tests, lint, typecheck pass; handler checked under astro dev.
Deploying nemar-website with
|
| Latest commit: |
623998a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d13cae8e.nemar-website.pages.dev |
| Branch Preview URL: | https://fix-logout-redirect-cross-ho.nemar-website.pages.dev |
This was referenced Sep 30, 2026
neuromechanist
added a commit
that referenced
this pull request
Sep 30, 2026
* test: pin the sign-out redirect in logout.ts * docs: mark the #385 Chrome cause as inferred
2 of 4 tasks
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.
Problem
Pressing Sign out ends the session but leaves the person on the same page.
Cause
The sign-out form POSTs to
/api/auth/logoutfromapp.nemar.org, and the handler answered303 -> /. The logout response clears the session cookie, so the follow-upGET /carries none, and since/is a marketing route the middleware answers301 -> https://nemar.org/.That last hop is cross-origin, and the page's CSP has
form-action 'self'. Chrome appliesform-actionto every hop of a form-submission redirect chain, so it refuses the hop. The cookie is already cleared by then, so the account is signed out and the page does not move.Checked against production over HTTP (no cookie):
POST app.nemar.org/api/auth/logout->303,location: /, cookie cleared, CSP ends inform-action 'self'GET app.nemar.org/->301,location: https://nemar.org/GET app.nemar.org/login->200The browser refusal itself is inferred from Chrome's documented
form-actionbehavior; it was not reproduced in a signed-in browser.Change
SIGNED_OUT_PATH = "/login"insrc/lib/auth.ts, with the reason next to it./loginis an app route, so the chain ends in one hop on the app host.src/pages/api/auth/logout.tsuses it for both the dev and production HTML branches.src/lib/host.test.tspins the invariant:SIGNED_OUT_PATHis an app route and is not cross-host redirected without a session, and/still is.The other option was to add
https://nemar.orgtoform-action, which widens the CSP on every page for one redirect. Not taken.Testing
bun run lint,bun run typecheck(0 errors),bun run test(2633 passed)astro dev: form POST returns303 -> /login, cookie cleared,/loginis200test.nemar.orgruns single-host mode, so the cross-host redirect that causes this cannot occur there (website#212); staging cannot show the before or after.