fix: proxy /api/* from Vite dev server to the backend#65
Merged
Conversation
…st:5173 health-check 'Unexpected token <' error)
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.
Summary
Hello page at http://localhost:5173 was rendering the error state with
Unexpected token '<', "<!doctype "... is not valid JSONbecause the Vite dev server has no route for/api/v1/*and falls back to servingindex.html.Fix
frontend/vite.config.ts— addserver.proxyforwarding/api/*to the backend. Target defaults tohttp://localhost:8000for host-mode dev; overridable viaVITE_API_PROXY_TARGETso docker-compose points athttp://app:8000(the in-network backend hostname).docker-compose.yml— setVITE_API_PROXY_TARGET=http://app:8000on the frontend service.Test plan
npm run checkcleannpm run lintcleannpm run format:checkcleannpm run test(2 passed)npm run buildcleannpm run dev, hit http://localhost:5173, the page should now render the greenOK v0.0.0+localbadge.🤖 Generated with Claude Code