You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
port: 5173,
// 天地图 Key 域名白名单为 slake.ali251.langye.net 时,本地可用 hosts 指向 127.0.0.1 后访问该域名
host: true,
allowedHosts: ['slake.ali251.langye.net', 'localhost', '127.0.0.1'],
proxy: {
// 与 Laravel `RouteServiceProvider` 中 `prefix('api')` 对齐,本地联调 slake-school-service
'/api': {
target: env.VITE_PROXY_TARGET || 'http://127.0.0.1:8000',
changeOrigin: true,
// 论文爬虫含 arXiv 多轮请求,避免代理 10s 默认超时
timeout: 300_000,
},
// 封面/宣传图等外链为 /storage/* 时,避免打到 Vite 5173 而 404
'/storage': {
target: env.VITE_PROXY_TARGET || 'http://127.0.0.1:8000',
changeOrigin: true,
},
},
},
}
})