47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
import { fileURLToPath, URL } from "node:url";
|
|
import { defineConfig, loadEnv } from "vite";
|
|
import vue from "@vitejs/plugin-vue";
|
|
|
|
const DEFAULT_API_TARGET = "http://127.0.0.1:8780";
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
const apiTarget = env.VITE_API_URL || DEFAULT_API_TARGET;
|
|
|
|
return {
|
|
plugins: [vue()],
|
|
resolve: {
|
|
alias: {
|
|
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
|
},
|
|
},
|
|
server: {
|
|
host: true,
|
|
port: 5174,
|
|
proxy: {
|
|
"/api/v1": {
|
|
target: apiTarget,
|
|
changeOrigin: true,
|
|
ws: true,
|
|
configure: (proxy) => {
|
|
proxy.on("proxyRes", (proxyRes) => {
|
|
const setCookie = proxyRes.headers["set-cookie"];
|
|
if (!setCookie) return;
|
|
proxyRes.headers["set-cookie"] = setCookie.map((cookie) =>
|
|
cookie
|
|
.replace(/;\s*Secure/gi, "")
|
|
.replace(/;\s*SameSite=None/gi, "; SameSite=Lax")
|
|
.replace(/;\s*Domain=[^;]+/gi, ""),
|
|
);
|
|
});
|
|
},
|
|
},
|
|
"/static": {
|
|
target: apiTarget,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|