fix(web): set changeOrigin on dev proxy targets#76
Merged
Conversation
Use the long-form Vite proxy config so the upstream Host header reflects the target instead of the local dev origin. Required when pointing VITE_API_PROXY_TARGET / VITE_TILES_PROXY_TARGET at https endpoints (e.g. beebeebike.com) where the upstream rejects mismatched hosts.
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
Switch the Vite dev-server proxy entries to long-form config with
changeOrigin: true(andsecure: falsefor self-signed cases).This is required when running the dev server against an HTTPS upstream — e.g.
Without
changeOrigin, the proxy forwardsHost: localhost:<port>upstream, which Cloudflare / nginx in front of beebeebike.com rejects. With it, the Host header matches the target and requests succeed.No effect on the default localhost compose setup — both proxies still point at the in-stack services when the env vars are unset.
Test plan
npm run devagainst localhost compose:/apiand/tilesstill proxy correctly.VITE_API_PROXY_TARGET=https://beebeebike.com VITE_TILES_PROXY_TARGET=https://beebeebike.com/tiles npm run dev:/api/auth/mereturns 401 (auth proxy reachable),/tiles/returns 200.