40 lines
877 B
TypeScript
40 lines
877 B
TypeScript
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
import { defineConfig } from 'vite'
|
|
|
|
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
|
const apiTarget = process.env.VITE_API_TARGET || 'http://127.0.0.1'
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(currentDir, 'src'),
|
|
},
|
|
},
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 5173,
|
|
// 隧道/自定义域名访问 dev server 时需加入白名单,否则 Vite 会拦截 Host
|
|
allowedHosts: [
|
|
'localhost',
|
|
'.localhost',
|
|
'127.0.0.1',
|
|
'221329.cc.cd',
|
|
'.cc.cd',
|
|
],
|
|
proxy: {
|
|
'/api': {
|
|
target: apiTarget,
|
|
changeOrigin: true,
|
|
},
|
|
'/health': {
|
|
target: apiTarget,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
})
|