fix: read VITE_API_BASE_URL from .env for Vite dev proxy#482
Open
octo-patch wants to merge 1 commit into666ghj:mainfrom
Open
fix: read VITE_API_BASE_URL from .env for Vite dev proxy#482octo-patch wants to merge 1 commit into666ghj:mainfrom
octo-patch wants to merge 1 commit into666ghj:mainfrom
Conversation
…j#480) The Vite development proxy target was hardcoded to http://localhost:5001, ignoring the VITE_API_BASE_URL environment variable that the axios client already respects. This caused the dev proxy to still route to localhost even when users configured a remote or custom backend address. - Use loadEnv() in vite.config.js to read VITE_API_BASE_URL from the project root .env file and pass it as the proxy target (fallback: localhost:5001) - Document VITE_API_BASE_URL in .env.example so users know the variable exists
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.
Fixes #480
Problem
The Vite development proxy target in
frontend/vite.config.jswas hardcoded tohttp://localhost:5001. Even when users setVITE_API_BASE_URLin their.envfile to point to a custom backend host or port, the dev proxy continued routing tolocalhost:5001— making the variable half-effective during development. Additionally,VITE_API_BASE_URLwas absent from.env.example, so users had no way to discover that the variable existed.Solution
frontend/vite.config.js: Switched fromdefineConfig({})to the function formdefineConfig(({ mode }) => { ... })and used Vite'sloadEnv()to readVITE_API_BASE_URLfrom the project root.envfile. The proxy target now falls back tohttp://localhost:5001when the variable is unset, preserving existing default behaviour..env.example: Added a commented-outVITE_API_BASE_URLentry with a short explanation, so users deploying on non-default hosts can discover and enable it without digging through source code.Testing
VITE_API_BASE_URLset): proxy still targetshttp://localhost:5001— no regression.VITE_API_BASE_URL=http://192.168.1.100:5001in.env):npm run devnow proxies API requests to the configured host, matching what the axios client already does at runtime.