chore: use different base url for different output

This commit is contained in:
2025-10-28 00:20:53 +08:00
parent 8dbdefb8b1
commit 1284698948
4 changed files with 8 additions and 1 deletions

2
.env Normal file
View File

@@ -0,0 +1,2 @@
# 开发环境配置
VITE_API_BASE_URL=http://127.0.0.1:8099

2
.env.production Normal file
View File

@@ -0,0 +1,2 @@
# 生产环境配置
VITE_API_BASE_URL=http://47.109.95.59:20080

View File

@@ -1,7 +1,7 @@
// API 配置 // API 配置
export const API_CONFIG = { export const API_CONFIG = {
BASE_URL: 'http://127.0.0.1:8099', BASE_URL: import.meta.env.VITE_API_BASE_URL || 'http://127.0.0.1:8099',
TIMEOUT: 10000, TIMEOUT: 10000,
HEADERS: { HEADERS: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View File

@@ -4,4 +4,7 @@ import react from '@vitejs/plugin-react'
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [react()],
// Vite 默认支持环境变量,无需额外配置
// 环境变量加载优先级:
// .env.local > .env.[mode] > .env
}) })