Skip to content

feat: serve the app under a base path - #2

Open
adamdickinson wants to merge 1 commit into
mainfrom
feat/base-path
Open

adamdickinson wants to merge 1 commit into
mainfrom
feat/base-path

Conversation

@adamdickinson

Copy link
Copy Markdown
Collaborator

Serve the app under a base path

Estimated time to review: 10 min (Small)

🎯 Intent
Lets the app run behind a proxy that serves it under a path, without changing how it runs anywhere else.
  • With BASE_PATH set, the app, its links and the mock API all live under that path.

  • Without it, everything stays at the root, as today.

⚠️ Risks 🔍 Focus
⚠️ Watch: the mock API middleware runs ahead of Vite's own, so it strips the base itself before handing the request to handlers written against the root.
  • Look at: vite-plugin-mock-api.ts

  • Skim: vite.config.ts, src/main.tsx, src/lib/api-client.ts, which each read the base from Vite

Motivation

The app assumed it was served from /: the router's links, the API client and
the mock API middleware all used root paths. Behind a proxy that forwards a path
such as /preview/, the page loaded but its routes and API calls missed.

Verification

  1. Run BASE_PATH=/preview/ bun run dev and open http://localhost:5173/preview/. Confirm the app loads, its scripts load from under /preview/, and /preview/api/me answers with JSON while /api/me is a 404.
  2. Run bun run dev with no BASE_PATH and confirm the app and /api/me still answer at the root.
  3. Run bun run typecheck, bun run lint and bun run test, and confirm they pass unchanged.

🤖 Generated with Claude Code

Set BASE_PATH to serve the app, its routes and the mock API under a path,
such as behind a proxy. Unset, everything stays at the root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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