Repository navigation
Keep marketing routes on the app host when signed in - #211
neuromechanist merged 2 commits into
Conversation
Deploying nemar-website with
|
| Latest commit: |
9de2044
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ccde40f1.nemar-website.pages.dev |
| Branch Preview URL: | https://210-signed-in-users-lose-the.nemar-website.pages.dev |
|
Good catch on finding 3 — that one was mine, and the mechanism is worth naming: Confirmed before fixing: Fixed in Also added a test pinning the exact case, since "canonical is right but the structured data beside it is wrong" is invisible in a preview by construction (single-host mode collapses both to the same origin) and would have shipped again otherwise: 1007 tests passing, typecheck 0 errors, lint clean. On the verification gapAgreed, and thanks for pushing further than I did rather than just restating it. Vite's DNS-rebinding protection rejecting a spoofed So the redirect suppression itself remains unverified end-to-end by either of us: not on the preview (single-host mode, redirects never fire), not locally (Host spoofing blocked). It is covered by unit tests on both directions plus your executed cache-poisoning test. I will verify the real flow on Particularly appreciated the mutation test on the cache skip: demonstrating that the pre-PR line really would have written the unresolved-cookie render into the shared cache is the difference between "this looks right" and "this is right". |
Closes #210.
Problem
Sign in at
app.nemar.org, click Discover, and you are signed out. Reported from real use.Three correct decisions combined into a wrong outcome:
/discoveris classified as a marketing route, sogetCrossHostRedirect301s it off the app host.app.nemar.organd does not follow./auth/meso its responses stay anonymous and edge-cacheable.The nav made it unavoidable rather than incidental: on the app host the primary nav collapsed to a single absolute link,
marketingUrl("/discover"). It left the app host by construction, so the only nav link a signed-in user had was the one that signed them out.This is distinct from the apex-cutover regression (#190), where
MARKETING_BASE_URLpointed at the legacy origin and ejected users onto the old HUBzero site. That was a bug in the destination. This is what remained once the destination was correct: the hop itself drops the session.Change
Marketing-bound redirects are suppressed when the request carries a session, so the app host renders the marketing route itself.
The suppression is deliberately one-directional, and that asymmetry is the load-bearing part:
Both directions are pinned by tests.
Cookie presence, not a resolved session
The redirect decision runs before
applySession, and resolving costs an/auth/meround-trip that a redirect would discard. So the check is cookie presence.A stale or forged cookie therefore buys nothing beyond a marketing page rendered on the app host instead of redirected: the page still resolves the session downstream and renders signed-out. Worst case is a slower anonymous render on the wrong host, not disclosure.
Two consequences that would otherwise be silent
Base.astroderived its origin from the serving host. That was right only because a marketing route could never be served by the app host — which is exactly what this PR changes. Left alone it would publishapp.nemar.org/discoveras canonical, competing with the marketing host for identical content. NewcanonicalOriginFor(pathname, hostname)resolves by route: app routes to the app host, everything else toMARKETING_BASE_URL. Single-host mode (localhost,*.pages.dev) is unchanged.Nav
On the app host the nav now depends on whether the user can be kept there:
/login) — unchanged single absolute link, since the redirect still fires and relative hrefs would only add a pointless hop.Tests
bun run test1006 passing, up from 976.typecheck0 errors,lintclean.One existing middleware test flipped, correctly: it asserted an app-host
/discover301 using a harness that always supplies a cookie, which is now precisely the case that must not redirect. Split into a cookie-less case (still 301s) and a cookie-bearing case (200), and added ananonCtxhelper since the old harness could no longer express both.Not verified
Dev-server and browser tooling were hanging in this environment, so this is covered by unit tests and reading rather than a live click-through. Worth exercising on a preview: sign in, click each nav link, confirm the user menu persists and the URL stays on the app host.