Repository navigation
Conversation
… was built A product born from this baseline could not log in. The console's `/v1/auth/login/start` never reached the edge: the preflight came back 204 with no `access-control-allow-origin`, so the browser refused the call and the login screen read "Failed to fetch" against an API that was answering 200 the whole time. The allowlist was built from a literal. `WORKERS_DEV_SUBDOMAIN` in `apps/api-edge/src/app-config.ts` is the one piece of a product's identity that is an *account* fact — the bootstrap only learns it after reading the Cloudflare connection, which is after the scaffold phase has already written the file and after the edge has been built from it. The edge therefore allowed a console on a subdomain that does not exist, and nothing anywhere failed: both halves typechecked, deployed and answered /health. Only a browser could see it. So the console's identity is now resolved per request, from the Worker's `vars` (`CONSOLE_WORKERS_DEV_SUBDOMAIN`, `CONSOLE_WORKER_PREFIX`), then the compiled-in constants, and — for the subdomain — additionally from the one the edge's OWN hostname names. The edge and the console are deployed to one Cloudflare account, so that last source is always right, whatever literal the bundle carries. Nothing widens. Each source yields one complete origin, matched whole: a suffix attack, a lookalike worker on the same subdomain, the wrong scheme and the wrong port all still fail, and stage still refuses the prod console. A custom-domain edge host names no workers.dev subdomain and contributes nothing. The same staleness has a second victim that cannot self-correct: `OAUTH_ALLOWED_CONSOLE_ORIGINS` in the identity worker is an open-redirect guard and is deliberately literal, so a stale subdomain there dead-ends OAuth sign-in after the provider hands the user back. A repo-wide guard now fails CI when two places name different workers.dev subdomains, naming the files — one of them is always a leftover placeholder. Verified against the live product: a tree rebranded to the placeholder the deployed bundle carries fails the preflight before this change and passes after, while every rejection case still rejects. 416 api-edge tests, 30 platform-limits, 258 console, 174 identity-worker green; the api-edge suite also green on a rebranded fork, so the new tests carry no baseline identity. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013NPmhw5whvKxZrZoPYYZtn
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.
A product born from this baseline cannot log in. Reported against
pullely/multi-tenant-saas; the login screen shows "Login failed — Failed tofetch".
What is actually wrong
The API is healthy. From an allowed origin the login endpoint answers fine:
From the console's own origin, the preflight comes back
204with noaccess-control-allow-origin, so the browser refuses the call andfetch()rejects — which is the only error the console can report:
The deployed edge allows a console on
test-multi-tenant-saas— theplaceholder subdomain from that repo's scaffold commit. Same on prod.
Why it happens
WORKERS_DEV_SUBDOMAINinapps/api-edge/src/app-config.tsis the one pieceof a product's identity that is an account fact. Every other name is known
when the repository is created; this one is known only after the Cloudflare
connection is read — after the scaffold phase has written the file and after
the edge has been built from it. Each bootstrap phase rewrites only its own
component's files, so a component built before the correction keeps the
placeholder.
Nothing fails when that happens. Both halves typecheck, deploy and answer
/health. Only a browser can see it.The fix
The console's identity is resolved per request now, from:
vars—CONSOLE_WORKERS_DEV_SUBDOMAIN,CONSOLE_WORKER_PREFIX;(3) is what makes it self-correcting: the edge and the console are deployed to
one Cloudflare account, so the subdomain in the edge's own hostname is the
console's, whatever literal the bundle carries.
This mirrors what the console already does for its own identity
(
saas-console-artifactCA1/CA2) — the edge was the half that never got it.Nothing widens. Each source yields one complete origin, matched whole:
suffix attack, lookalike worker on the same subdomain, wrong scheme, wrong port
all still rejected, and
stagestill refuses theprodconsole. Acustom-domain edge host names no workers.dev subdomain and contributes nothing.
The second victim, which cannot self-correct
The same staleness is sitting in
apps/identity-worker'sOAUTH_ALLOWED_CONSOLE_ORIGINS— stilltest-multi-tenant-saasin thatproduct at HEAD, so OAuth sign-in dead-ends after the provider hands the user
back. That one is an open-redirect guard and is deliberately literal: it cannot
derive anything. So
tests/platform-limits/src/console-origin-agreement.test.tsnow fails CI when two places in the repo name different workers.dev subdomains,
listing the files — one of them is always a leftover placeholder.
Run against
pullely/multi-tenant-saasas it stands, it reports exactly that:Verification
bundle actually carries: the preflight fails before this change and
passes after, with every rejection case still rejecting.
another product's identity — the test literals derive from the seam, so they
do not silently collapse into tautologies after a rename.
identity-worker tests green; typecheck and lint clean. Pre-existing on this
branch and untouched: 6
verify-bindingsservice-name mismatches inapps/api-edge.Not in this PR
This fixes the baseline.
pullely/multi-tenant-saasstill needs, separately:a redeploy of
api-edge(itsapp-config.tsat HEAD is already correct, onlythe deployed bundle is stale), and the subdomain corrected in
apps/identity-worker/wrangler.template.jsonc, which is wrong in therepository itself.
Generated by Claude Code