feat: API 代理地址支持环境变量配置,本地开发指向 127.0.0.1:3000
All checks were successful
Deploy Admin Frontend / build-and-deploy (push) Successful in 13s

This commit is contained in:
wangdl 2026-06-27 12:42:48 +08:00
parent 8da983b0eb
commit 7c802bdf47
2 changed files with 28 additions and 22 deletions

1
.gitignore vendored
View File

@ -22,3 +22,4 @@ dist-ssr
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
.env

View File

@ -1,9 +1,13 @@
import { defineConfig } from 'vite' import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite' import tailwindcss from '@tailwindcss/vite'
import path from 'node:path' import path from 'node:path'
export default defineConfig({ export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const apiBase = env.VITE_API_BASE_URL || 'https://api.longde.cloud'
return {
plugins: [react(), tailwindcss()], plugins: [react(), tailwindcss()],
resolve: { resolve: {
alias: { '@': path.resolve(import.meta.dirname, 'src') }, alias: { '@': path.resolve(import.meta.dirname, 'src') },
@ -24,8 +28,9 @@ export default defineConfig({
server: { server: {
port: 5174, host: true, port: 5174, host: true,
proxy: { proxy: {
'/api': 'https://api.longde.cloud', '/api': apiBase,
'/admin-api': 'https://api.longde.cloud', '/admin-api': apiBase,
}, },
}, },
}
}) })