Repository navigation
Conversation
🐕 Shuni ReviewNo new issues found. 🤖 Model: Review scope: Partial incremental re-review Reviewed new changes (1)
🐕 Review complete — View session on Shuni Portal 🐾 🤖 Model: |
tomski747
force-pushed
the
feat/auth-prefix-relative-paths
branch
from
October 22, 2026 14:56
fb3499c to
82228f5
Compare
When auth-hosting is served under a path prefix (e.g. a vanity domain at https://host/auth/login/<pid>), the API base URL and content base URL were built from the bare window.location.origin, so /v1/flow/validate-domain and /pages/<pid>/... were requested at the root and 404ed. Derive the prefix from whatever precedes the /login segment in the pathname and apply it to both. Root-mounted custom domains keep an empty prefix and behave as before. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…efix PUBLIC_URL=. for production builds makes index.html reference ./env.js and ./static/... which resolve against the document URL, so /auth/login/<pid> loads /auth/login/env.js instead of /login/env.js. trailingSlash: false keeps relative resolution correct by redirecting /login/<pid>/ to /login/<pid>. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… tag Relative ./env.js and ./static/... only resolved correctly when the document path had a segment after /login. On /auth/login (no project id) they resolved to /auth/env.js, and the Vercel trailing-slash redirect dropped the /auth prefix because the edge strips it before Vercel. An inline bootstrap now sets <base href> to everything up to and including the login segment, so assets resolve to <prefix>/login/... for /login, /login/<pid>/ and /auth/login/<pid> alike. The trailingSlash setting is no longer needed and is removed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The asset root is the mount prefix itself, not <prefix>/login: the base tag now points at everything before the login segment, so ./env.js resolves to /env.js on root domains and /auth/env.js on a vanity host. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…h/env.js)" This reverts commit 64c268e.
tomski747
force-pushed
the
feat/auth-prefix-relative-paths
branch
from
November 19, 2026 14:07
48d9297 to
1cc3e69
Compare
tomski747
enabled auto-merge (squash)
November 19, 2026 14:07
tomski747
disabled auto-merge
November 19, 2026 14:07
This branch was successfully deployed
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
On a vanity domain the app is served under an
/auth/prefix:https://vanity-domain.descope.team/auth/login/<pid>. A customer demo HAR showed two classes of wrong URLs:window.location.origin404s:POST /v1/flow/validate-domain,GET /pages/<pid>/v2-beta/config.json,theme.json. Becauseconfig.jsonfails, the web component then requests@descope/web-components-ui@undefinedfrom the CDNs (downstream symptom).env.jsandstatic/*are requested at/login/...rather than/auth/login/.... They only work today because the edge also serves/login/*on vanity hosts, which we want to retire.Regular custom domains served at the root (
https://host/login/<pid>) must keep working.Fix
Runtime URLs (commit 1). New helper
src/shared/basePath.ts:getBasePath(pathname)returns everything before the/loginsegment (package.jsonhomepage), so""for root mounts,/authfor the vanity case, and any other nested prefix. Nothing is hardcoded toauth. Applied inApp.tsx(REACT_APP_USE_ORIGIN_BASE_URLbase),index.tsx(origin-relativeREACT_APP_CONTENT_BASE_URL; absolute values untouched) andWelcome.tsx(example URL). Unit tests cover no prefix,/auth, nested prefix, trailing slash / missing project id, no/loginsegment, and thewindow.locationdefault.Build-time asset URLs (commits 2-3).
.env.productionsetsPUBLIC_URL=.so the production build emits./env.js,./static/js/...,./static/css/...and webpack public path./. Relative paths alone are not enough: on/auth/login(no project id)./env.jsresolves to/auth/env.js, and a Vercel trailing-slash redirect cannot help because the edge strips/authbefore Vercel sees the request (observed:/auth/login/<pid>/-> 308 to/login/<pid>). Sopublic/index.htmlnow has an inline bootstrap that sets<base href>to everything up to and including theloginsegment of the pathname. Assets then resolve to/login/env.jsand/login/static/...on root domains and/auth/login/env.jsand/auth/login/static/...on the vanity host, for/login,/login/<pid>,/login/<pid>/,/auth/login/<pid>and nested prefixes alike. The Descope edge strips/authand routes/login*to Vercel, where the existing/login/:path*->/:path*rewrite serves the files, so no edge change is needed. Dev is unchanged (CRA ignores a relativePUBLIC_URLin development and falls back tohomepage, i.e./login).Verified in Chrome against the production build served behind a local edge simulator (strips the prefix, applies the
/loginrewrite): for each of/auth/login/<pid>,/auth/login/<pid>/,/auth/login,/login,/login/<pid>,/a/b/login/<pid>/, env.js, main.js and main.css load from<prefix>/login/...with 200.Checked and left alone
middleware.tsfetches/.well-known/project-configuration/<pid>fromMIDDLEWARE_DESCOPE_BASE_URL, not the request origin, and reads the project id from the last path segment, so the prefix does not affect it.App.tsxpreserveswindow.location.pathname, so the prefix survives./login/:path*rewrite is kept; Vercel-origin requests are unchanged.Infra to confirm
/login/*on the vanity host anymore, so that edge route can be retired for this app once this is deployed.Verification
yarn test: 4 suites, 75 tests pass.eslint src middleware.ts --max-warnings 0and prettier: clean.yarn lint:cihas one pre-existing parsing error inconfig-overrides.js(not intsconfig.json), unrelated.yarn buildcompiles successfully; the built head contains the base bootstrap and relative asset references.🤖 Generated with Claude Code