Skip to content

fix: make vite proxy target configurable via environment variable#104

Open
nil957 wants to merge 1 commit into666ghj:mainfrom
nil957:fix/remove-hardcoded-api-url
Open

fix: make vite proxy target configurable via environment variable#104
nil957 wants to merge 1 commit into666ghj:mainfrom
nil957:fix/remove-hardcoded-api-url

Conversation

@nil957
Copy link

@nil957 nil957 commented Mar 9, 2026

Summary

This PR addresses issue #93 - frontend/src/api/index.js中的baseURL不应该硬编码

Problem

While api/index.js already supports VITE_API_BASE_URL, the vite dev server proxy in vite.config.js was still hardcoded to http://localhost:5001, causing issues when:

  • Deploying with Docker using custom port mappings
  • Running backend on a remote server
  • Using non-standard ports

Changes

  1. Updated vite.config.js to read VITE_API_BASE_URL from environment variables
  2. Added documentation in .env.example for the new configuration option

Usage

# In .env file
VITE_API_BASE_URL=http://your-backend-host:5001

If not set, it defaults to http://localhost:5001 for backward compatibility.

Closes #93

Changes:
- Update vite.config.js to read VITE_API_BASE_URL from environment
- Add VITE_API_BASE_URL documentation to .env.example

This allows users to configure the backend API URL without modifying
the source code, which is especially useful for:
- Docker deployments with custom port mappings
- Remote server deployments
- Development with backend running on a different host

The api/index.js already supports VITE_API_BASE_URL, this change
ensures the vite dev server proxy is also configurable.

Closes 666ghj#93
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. documentation Improvements or additions to documentation labels Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

frontend/src/api/index.js中的baseURL不应该硬编码

1 participant