Files
LinyeZhanshi/vite.config.js

22 lines
580 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vite.dev/config/
export default defineConfig({
plugins: [vue()],
server: {
proxy: {
// 只要你请求以 /api 开头,就会被转发到目标服务器
'/api': {
target: 'http://192.168.1.254:9001',
changeOrigin: true,
// 如果后端路径本身就有 /api就不需要 rewrite
// 如果你希望把 /api 前缀去掉再转发,就打开下面这行:
// rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
})