Repository navigation
feat: serve the app under a base path - #2
Open
adamdickinson wants to merge 1 commit into
Open
adamdickinson wants to merge 1 commit into
adamdickinson wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Serve the app under a base path
Estimated time to review: 10 min (Small)
With
BASE_PATHset, the app, its links and the mock API all live under that path.Without it, everything stays at the root, as today.
Look at:
vite-plugin-mock-api.tsSkim:
vite.config.ts,src/main.tsx,src/lib/api-client.ts, which each read the base from ViteMotivation
The app assumed it was served from
/: the router's links, the API client andthe 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
BASE_PATH=/preview/ bun run devand openhttp://localhost:5173/preview/. Confirm the app loads, its scripts load from under/preview/, and/preview/api/meanswers with JSON while/api/meis a 404.bun run devwith noBASE_PATHand confirm the app and/api/mestill answer at the root.bun run typecheck,bun run lintandbun run test, and confirm they pass unchanged.🤖 Generated with Claude Code