feat: API 代理地址支持环境变量配置,本地开发指向 127.0.0.1:3000
All checks were successful
Deploy Admin Frontend / build-and-deploy (push) Successful in 13s
All checks were successful
Deploy Admin Frontend / build-and-deploy (push) Successful in 13s
This commit is contained in:
parent
8da983b0eb
commit
7c802bdf47
1
.gitignore
vendored
1
.gitignore
vendored
@ -22,3 +22,4 @@ dist-ssr
|
|||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
.env
|
||||||
|
|||||||
@ -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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user