Skip to content

fix(web): drop the invalid hosted /s/ rewrite (basePath build break)#2003

Merged
itachi-hue merged 2 commits into
mainfrom
fix/s-rewrite-basepath-build
Jun 25, 2026
Merged

fix(web): drop the invalid hosted /s/ rewrite (basePath build break)#2003
itachi-hue merged 2 commits into
mainfrom
fix/s-rewrite-basepath-build

Conversation

@itachi-hue

Copy link
Copy Markdown
Collaborator

Problem

The dashboard next.config.ts emits a /s/:path* rewrite under basePath="/app":

...(APP_BASE_PATH ? [{ source: "/s/:path*", destination: `${APP_BASE_PATH}/s/:path*`, basePath: false }] : [])

Next.js rejects it: "rewrites urls outside of the basePath. Please use a destination that starts with http(s)://" → Error: Invalid rewrite foundnpm run build exits 1. It only triggers when NEXT_PUBLIC_BASE_PATH is 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:false shape 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 this basePath="/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) serves app/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.

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>
@itachi-hue itachi-hue merged commit efd961c into main Jun 25, 2026
7 checks passed
@itachi-hue itachi-hue deleted the fix/s-rewrite-basepath-build branch June 25, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant