vite.config.js 797 B

12345678910111213141516171819202122232425
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. export default defineConfig({
  4. plugins: [vue()],
  5. server: {
  6. port: 5173,
  7. host: true,
  8. proxy: {
  9. // 开发环境走同源代理,规避浏览器 CORS。
  10. // 前端请求 /agent-api/xxx -> 实际转发到 http://127.0.0.1:9999/xxx
  11. '/agent-api': {
  12. target: 'http://127.0.0.1:9999',
  13. changeOrigin: true,
  14. // SSE 需要长连接,关闭超时
  15. timeout: 0,
  16. proxyTimeout: 0,
  17. rewrite: (path) => path.replace(/^\/agent-api/, '')
  18. }
  19. // 如需接入其它后端主机,再加一条,例如:
  20. // '/agent-8000': { target: 'http://127.0.0.1:8000', changeOrigin: true,
  21. // rewrite: (p) => p.replace(/^\/agent-8000/, '') }
  22. }
  23. }
  24. })