Conversation
|
|
There was a problem hiding this comment.
Code Review
This pull request updates database migration scripts to change a descriptive string from '亚谋理想项目测试使用' to '项目测试使用' across several entries in V1.13__insert_config_data.sql and V1.14__insert_config_data2.sql. Additionally, it cleans up the vite.config.js file by removing numerous commented-out proxy target configurations. A review comment suggests that the hardcoded IP address in vite.config.js should be replaced with an environment variable for better flexibility and to avoid leaking internal network information.
| // target: 'http://10.1.196.7:8080', // 旭东 | ||
| // target: 'http://10.1.203.40:8080', // 彭颖 | ||
| // target: 'http://10.1.200.151:8080', // 超睿 | ||
| target: 'http://172.29.202.54:8080', // 联调服务器地址 |
There was a problem hiding this comment.
Hardcoding IP addresses in configuration files should be avoided. It makes the configuration inflexible for other developers and can leak internal network information.
It's recommended to use environment variables for this kind of configuration. Vite has built-in support for .env files.
You can refactor this to use loadEnv:
-
In your
.envor.env.developmentfile, add:VITE_API_PROXY_TARGET=http://172.29.202.54:8080 -
Then, update
vite.config.jsto load and use this variable:import { defineConfig, loadEnv } from 'vite'; export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ''); return { // ... other config server: { proxy: { '/xingchen-api': { target: env.VITE_API_PROXY_TARGET, changeOrigin: true, }, // ... }, }, // ... }; });
This makes the proxy target easily configurable without changing the code.
Summary
Type of Change
Related Issue
Changes
Testing
Screenshots (if applicable)
Checklist