Skip to content

fix(web,docs): unbreak prefixed-locale routes and /docs redirects#1691

Merged
yannickmonney merged 1 commit into
mainfrom
fix/web-spa-base-and-docs-redirect-prefix
May 8, 2026
Merged

fix(web,docs): unbreak prefixed-locale routes and /docs redirects#1691
yannickmonney merged 1 commit into
mainfrom
fix/web-spa-base-and-docs-redirect-prefix

Conversation

@yannickmonney

@yannickmonney yannickmonney commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Two regressions surfaced after #1690's locale-negotiation rollout:

  • services/web — Vite's base: './' made dist/index.html reference ./assets/.... The SPA shell is the fallback for any non-prerendered route, so the new redirect /pricing/de/pricing resolved the relative URL against /de/ and requested /de/assets/index-XXX.js. That path falls back to index.html again with Content-Type: text/html, the browser refuses the module, page is blank. Switch to base: '/' so the shell is self-contained at any depth.
  • services/docs — Caddy mounts docs at /docs via handle_path /docs* (strips the prefix). The server emitted Location: /de, which is origin-relative → browser landed on the web site's /de instead of /docs/de. Promote DOCS_BASE_URL to 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)

$ curl -sI -H "Cookie: tale_locale=de" https://tale.dev/docs
HTTP/2 302
location: /de            ← should be /docs/de

$ curl -sI https://tale.dev/de/assets/index-CLmaLWA4.js
HTTP/2 200
content-length: 2090     ← the SPA fallback HTML, not JS

Playwright at /de/pricing: blank, console error Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "text/html".

Test plan

  • After deploy, curl -sI -H "Cookie: tale_locale=de" https://tale.dev/docs returns Location: /docs/de
  • After deploy, https://tale.dev/de/pricing renders the German pricing page (no module-MIME error in devtools)
  • https://tale.dev/pricing (English) still renders correctly
  • https://tale.dev/docs (English) still renders the docs landing page
  • i18n package tests still pass (45 tests, verified locally)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Configuration Updates
    • Documentation service now supports deployment under custom paths for flexible hosting configurations.
    • Web application asset loading updated for consistent reference handling across different URL structures.

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>
@yannickmonney yannickmonney merged commit 1b176e6 into main May 8, 2026
12 of 13 checks passed
@yannickmonney yannickmonney deleted the fix/web-spa-base-and-docs-redirect-prefix branch May 8, 2026 22:27
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR enables sub-path mounting for the docs and web services. The docs Dockerfile now passes DOCS_BASE_URL from build-time arguments into the runtime environment. The docs server reads this value, derives a normalized BASE_PATH, and prefixes locale-negotiation redirects with it. The web app's Vite configuration switches from a relative base (./) to an absolute base (/) to ensure consistent asset loading from nested routes. These changes allow both services to operate correctly when served from non-root paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • tale-project/tale#1684: Related changes to docs Dockerfile and base path configuration for sub-path mounting support.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fixes: correcting prefixed-locale routes in web and /docs redirects, matching the primary changes in vite.config.ts and server.ts.
Description check ✅ Passed The description provides a clear summary with context, reproduction steps, and a detailed test plan, though the pre-merge checklist is incomplete with unchecked boxes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/web-spa-base-and-docs-redirect-prefix

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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