fix(web,docs): unbreak prefixed-locale routes and /docs redirects#1691
Conversation
Two regressions surfaced after #1690's locale negotiation rolled out: 1. services/web — Vite's `base: './'` made `dist/index.html` reference `./assets/...`. The SPA shell is the fallback for any non-prerendered route, so a redirect like `/pricing` → `/de/pricing` resolved the relative URL against `/de/` and requested `/de/assets/index-XXX.js`, which falls back to `index.html` again with `Content-Type: text/html`. The browser refused the module → blank page. Switching to `base: '/'` makes the shell self-contained at any depth. 2. services/docs — Caddy mounts docs at `/docs` via `handle_path /docs*`, stripping the prefix before proxying. The server's locale negotiator emitted `Location: /de`, which is origin-relative → the browser landed on the web site's German page instead of /docs/de. Promote `DOCS_BASE_URL` to a runtime env on the runner stage and prepend it to the redirect target. Empty (default `/`) preserves the existing docs.tale.dev behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR enables sub-path mounting for the docs and web services. The docs Dockerfile now passes Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Two regressions surfaced after #1690's locale-negotiation rollout:
base: './'madedist/index.htmlreference./assets/.... The SPA shell is the fallback for any non-prerendered route, so the new redirect/pricing→/de/pricingresolved the relative URL against/de/and requested/de/assets/index-XXX.js. That path falls back toindex.htmlagain withContent-Type: text/html, the browser refuses the module, page is blank. Switch tobase: '/'so the shell is self-contained at any depth./docsviahandle_path /docs*(strips the prefix). The server emittedLocation: /de, which is origin-relative → browser landed on the web site's/deinstead of/docs/de. PromoteDOCS_BASE_URLto a runtime env on the runner stage and prepend it to the redirect target. Default (/) is a no-op, preserving the existing docs.tale.dev deployment.Reproduction (before)
Playwright at
/de/pricing: blank, console errorFailed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "text/html".Test plan
curl -sI -H "Cookie: tale_locale=de" https://tale.dev/docsreturnsLocation: /docs/dehttps://tale.dev/de/pricingrenders the German pricing page (no module-MIME error in devtools)https://tale.dev/pricing(English) still renders correctlyhttps://tale.dev/docs(English) still renders the docs landing pagei18npackage tests still pass (45 tests, verified locally)🤖 Generated with Claude Code
Summary by CodeRabbit