-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
27 lines (25 loc) · 787 Bytes
/
Copy pathvite.config.ts
File metadata and controls
27 lines (25 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const n8nBaseUrl = env.VITE_N8N_BASE_URL || "https://localhost";
const parsed = new URL(n8nBaseUrl);
const proxyTarget = parsed.origin;
const apiBasePath = parsed.pathname.replace(/\/$/, "");
return {
plugins: [react(), tailwindcss()],
server: {
proxy: {
"/api/n8n": {
target: proxyTarget,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api\/n8n/, apiBasePath),
headers: {
"X-N8N-API-KEY": env.VITE_N8N_API_KEY || "",
},
},
},
},
};
});