fix(web): drop the invalid hosted /s/ rewrite (basePath build break)#2003
Merged
Conversation
The dashboard next.config emitted a /s/:path* rewrite under basePath="/app"
whose destination (`${APP_BASE_PATH}/s/:path*` with basePath:false) is rejected
by Next.js -- "rewrites urls outside of the basePath. Please use a destination
that starts with http(s)://" -- breaking every hosted (basePath) build. It only
triggers when NEXT_PUBLIC_BASE_PATH is set, so the OSS CI never hit it.
It was also ineffective: on a hosted host the apex `/s/*` URL reaches the LANDING,
not this basePath="/app" dashboard, so `/s/*` must be rewritten into `/app/s/*`
at the apex (mirroring how `/app/*` is served), not self-rewritten here. OSS (no
basePath) serves /s/[token] directly with no rewrite.
Verified `next build` with NEXT_PUBLIC_BASE_PATH=/app now compiles (previously
failed at config validation with "Invalid rewrite found").
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The prior test enforced the now-removed /s/ rewrite (the one that broke hosted basePath builds). Flip it to assert next.config.ts no longer contains the /s/ rewrite — /s/* is handled at the hosted apex (-> /app/s/*), OSS serves /s/[token] directly. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Problem
The dashboard
next.config.tsemits a/s/:path*rewrite underbasePath="/app":Next.js rejects it: "rewrites urls outside of the basePath. Please use a destination that starts with
http(s)://" →Error: Invalid rewrite found→npm run buildexits 1. It only triggers whenNEXT_PUBLIC_BASE_PATHis set, so the OSS CI (no basePath) never hit it — but every hosted build fails. (Surfaced when the cloud wrapper bumped to this engine and the dashboard build broke.)Note the contrast with
cloudApexRedirects(), which uses the same${APP_BASE_PATH}/…+basePath:falseshape but as redirects (allowed) — rewrites with a relative cross-basePath destination are not.Why removing it is correct (not just a build patch)
The rewrite was also ineffective: on a hosted host, the public
/s/*URL hits the landing apex, not thisbasePath="/app"dashboard. So/s/*must be rewritten into/app/s/*at the apex (exactly how/app/*is already served), never self-rewritten in the dashboard. OSS (no basePath) servesapp/s/[token]directly with no rewrite. The block is therefore dead + invalid config.Fix
Remove the broken hosted
/s/rewrite (replaced with a comment explaining the apex is responsible).Verification
NEXT_PUBLIC_BASE_PATH=/app next build→ previously failed at config validation; now✓ Compiled successfully.Follow-up (cloud side, separate): the hosted apex/landing adds the
/s/* → /app/s/*rewrite so the public share URL resolves.