61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import path from 'path'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
// 配置服务器中间件
|
|
plugins: [
|
|
vue(),
|
|
AutoImport({
|
|
resolvers: [ElementPlusResolver()],
|
|
imports: ['vue', 'vue-router', 'pinia'],
|
|
dts: 'src/auto-import.d.ts',
|
|
}),
|
|
Components({
|
|
resolvers: [ElementPlusResolver(), AntDesignVueResolver({ importStyle: 'less' })],
|
|
dts: 'src/components.d.ts',
|
|
}),
|
|
// 添加 IP 访问控制中间件
|
|
{
|
|
name: 'ip-access-control',
|
|
configureServer(server) {
|
|
// 暂时禁用 IP 访问控制,允许所有 IP 访问
|
|
// 生产环境应该重新启用并配置正确的 IP 列表
|
|
server.middlewares.use((_req, _res, next) => {
|
|
// 直接允许所有 IP 访问
|
|
next()
|
|
})
|
|
},
|
|
},
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
host: true,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://wcy111.top:8088', // 代理到 Gateway
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
},
|
|
},
|
|
// 配置允许的主机名
|
|
allowedHosts: [
|
|
'localhost',
|
|
'127.0.0.1',
|
|
'2666.online', // 允许通过 2666.online 访问
|
|
'wcy111.top', // 允许通过 wcy111.top 访问
|
|
// 可以添加更多允许的域名
|
|
],
|
|
},
|
|
})
|