Initial commit: Vue rewrite frontend
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user