Skip to content

fix(client): route gateway same-origin for any deployment subdomain (renamed-app 404) - #14

Merged
HomemadeToast57 merged 2 commits into
mainfrom
fix/gateway-slug-rename-404
Jul 22, 2026
Merged

HomemadeToast57 merged 2 commits into
mainfrom
fix/gateway-slug-rename-404

Conversation

@HomemadeToast57

Copy link
Copy Markdown
Collaborator

The bug

A generated app served at funky-ninja.bool.so has its slug/domain changed after it was built. Clicking Continue with Google opens a tab that 404s. (Same root cause silently 404s the app's data/gateway calls too — Google is just the one that navigates a visible tab.)

Root cause

boolGatewayBase() picked the same-origin (relative) path only when the live host exactly equaled the build-time-baked slug's subdomain:

location.host === slug + "." + appHost   // slug = baked VITE_BOOL_SLUG

Vite inlines every VITE_* at build time, so VITE_BOOL_SLUG is frozen into the bundle. Renaming the project (app/api/projects/[id]/route.ts PATCH slug) does not rebuild — so the live app at <new-slug>.bool.so still carries the old baked slug. The exact match fails, the client falls through to the absolute branch `${appOrigin}/served/<old-slug>`, and the gateway (handleGatewayUsers, which resolves the tenant by slug) 404s because the old slug is gone.

Fix

The platform proxy (proxy.tsdeploymentSlugFromHost) resolves the gateway slug from the request host, not the baked slug — so any <label>.<appHost> deployment subdomain is reachable same-origin. Match on that subdomain shape instead of the baked slug (isDeploymentSubdomain, mirroring the proxy). Renamed apps stay same-origin and just work, with no rebuild.

  • Preview sandboxes (*.vercel.run) and custom domains are unchanged — they still use the cross-origin baked-origin path.
  • No public API change: isDeploymentSubdomain is exported from client.ts for tests but not re-exported from index.ts.

Tests

bun test — 106 pass. Adds a renamed-app regression (live subdomain ≠ baked slug → still relative) and direct unit coverage of isDeploymentSubdomain (port stripping, apex, multi-label, foreign domains, empty inputs).

Release note

This reaches already-deployed apps only on their next publish build (the SDK is bundled at build time). Needs a canary/next publish to roll out; stable ^0.1.x apps pick it up on their next build per the caret range.

🤖 Generated with Claude Code

HomemadeToast57 and others added 2 commits July 22, 2026 17:04
The gateway base was chosen by comparing the live host to the
build-time-baked VITE_BOOL_SLUG (location.host === `${slug}.${appHost}`).
Vite inlines VITE_* at build time, so when a project's slug/domain is
changed after the bundle is built, the baked slug goes stale: the app is
served at `<new-slug>.<appHost>`, the exact match fails, and the client
falls through to an absolute `${appOrigin}/served/<old-slug>` gateway URL.
That slug no longer exists, so every gateway call 404s — most visibly the
"Continue with Google" navigation, which opens a tab straight onto the
404.

The platform proxy resolves the gateway slug from the REQUEST host, not
the baked slug, so any `<label>.<appHost>` deployment subdomain is
reachable same-origin. Detect that shape (new isDeploymentSubdomain,
mirroring the proxy's deploymentSlugFromHost) instead of matching the
baked slug. Renamed apps now stay same-origin and keep working with no
rebuild. Preview sandboxes and custom domains are unchanged (still the
cross-origin baked-origin path).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@HomemadeToast57
HomemadeToast57 merged commit cec7ced into main Jul 22, 2026
3 checks passed
@HomemadeToast57
HomemadeToast57 deleted the fix/gateway-slug-rename-404 branch July 22, 2026 22:22
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