Update service URLs and the Vite proxy rewrite so requests match /content/, /cms/, and /common/ mounts after /api is stripped. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
692 B
JavaScript
30 lines
692 B
JavaScript
import { defineConfig } from "vite";
|
||
import react from "@vitejs/plugin-react";
|
||
import path from "path";
|
||
|
||
// https://vite.dev/config/
|
||
export default defineConfig({
|
||
plugins: [react()],
|
||
resolve: {
|
||
alias: {
|
||
"@": path.resolve(__dirname, "./src"),
|
||
},
|
||
},
|
||
server: {
|
||
open: "/",
|
||
host: "0.0.0.0", //wsl中使用
|
||
proxy: {
|
||
// 前端仍请求 /api/*,转发到 Django 时剥掉 /api(与线上网关一致)
|
||
"/api": {
|
||
target: "http://127.0.0.1:8000",
|
||
changeOrigin: true,
|
||
rewrite: (p) => p.replace(/^\/api/, ""),
|
||
},
|
||
"/media": {
|
||
target: "http://127.0.0.1:8000",
|
||
changeOrigin: true,
|
||
},
|
||
},
|
||
},
|
||
});
|