chore: update dev server config

This commit is contained in:
Steven 2023-09-30 01:23:25 +08:00
parent 8c753e9557
commit 6ee6a5166e

View File

@ -2,6 +2,12 @@ import react from "@vitejs/plugin-react-swc";
import { resolve } from "path"; import { resolve } from "path";
import { defineConfig } from "vite"; import { defineConfig } from "vite";
let devProxyServer = "http://localhost:8082/";
if (process.env.DEV_PROXY_SERVER && process.env.DEV_PROXY_SERVER.length > 0) {
console.log("Use devProxyServer from environment: ", process.env.DEV_PROXY_SERVER);
devProxyServer = process.env.DEV_PROXY_SERVER;
}
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [react()],
@ -9,13 +15,17 @@ export default defineConfig({
host: "0.0.0.0", host: "0.0.0.0",
port: 3000, port: 3000,
proxy: { proxy: {
"/api/": { "^/api": {
target: "http://localhost:8082/", target: devProxyServer,
changeOrigin: true, xfwd: true,
}, },
"/s/": { "^/slash.api.v2": {
target: "http://localhost:8082/", target: devProxyServer,
changeOrigin: true, xfwd: true,
},
"^/s/": {
target: devProxyServer,
xfwd: true,
}, },
}, },
}, },