import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' // https://vite.dev/config/ export default defineConfig({ base: './', plugins: [vue()], resolve: { alias: { '@': path.resolve(__dirname, './src') } }, server: { proxy: { '/apiV1': { // 配置需要代理的路径 --> 这里的意思是代理http://localhost:80/api/后的所有路由 target: 'https://www.workark.com', // 目标地址 --> 服务器地址 changeOrigin: true, // 允许跨域 ws: true, // 允许websocket代理 // 重写路径 --> 作用与vue配置pathRewrite作用相同 rewrite: (path) => path.replace(/^\/apiV1/, "") } }, } })