build(frontend): load backend url for vite dev proxy from env

This commit is contained in:
2025-03-07 16:31:41 +01:00
parent 5f1404c7d7
commit d4f194b146
4 changed files with 26 additions and 3 deletions

View File

@ -1,8 +1,10 @@
import { defineConfig } from "vite";
import { defineConfig, loadEnv } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import routify from "@roxi/routify/vite-plugin";
import tailwindcss from "@tailwindcss/vite";
const env = loadEnv(process.env.NODE_ENV as string, process.cwd(), "VITE_");
export default defineConfig({
plugins: [
routify({
@ -15,11 +17,11 @@ export default defineConfig({
host: true,
proxy: {
"/api": {
target: "http://10.10.39.145:3000",
target: env.VITE_BACKEND_URL || "http://localhost:3000",
changeOrigin: true,
},
"/socket.io": {
target: "http://10.10.39.145:3000",
target: env.VITE_BACKEND_URL || "http://localhost:3000",
ws: true,
changeOrigin: true,
},