vite.config.ts 556 B

123456789101112131415161718
  1. import { defineConfig } from "vite";
  2. import react from "@vitejs/plugin-react";
  3. // https://vitejs.dev/config/
  4. export default defineConfig({
  5. plugins: [react()],
  6. base: "/protocols/",
  7. server: {
  8. // Swagger UI 带 withCredentials 发请求,跨域时后端的 Access-Control-Allow-Origin: *
  9. // 会被浏览器拒绝。这里代理成同源请求,"Try it out" 就能直接打本地后端。
  10. proxy: {
  11. "/api": {
  12. target: process.env.VITE_API_TARGET ?? "http://127.0.0.1:8000",
  13. changeOrigin: true,
  14. },
  15. },
  16. },
  17. });