From 57e2a33dc619d209cc271a1cb5ecb3f141834fce Mon Sep 17 00:00:00 2001 From: MidoriKurage Date: Sat, 21 Mar 2026 21:34:51 +0800 Subject: [PATCH] fix(frontend/vite): Configure vite dev proxy to handle frontend path --- frontend/vite.config.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 46ce0eb22..8c2ed69bf 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -269,16 +269,25 @@ function getBuildConfig(env: Record) { function getServeConfig(env: Record) { // get some default settings from prod mod const buildConfig = getBuildConfig(env) + + // Build the proxy pattern from VIKUNJA_FRONTEND_BASE so that custom base + // paths like /vikunja proxy /vikunja/api/* correctly. + // Falls back to /api. + const base = (env.VIKUNJA_FRONTEND_BASE || '/').replace(/\/+$/, '') + const proxyPath = `${base}/api` + // override prod settings with dev settings return { ...buildConfig, server: { ...buildConfig.server, ...(env.DEV_PROXY && { proxy: { - '/api': { + [proxyPath]: { target: env.DEV_PROXY, changeOrigin: true, secure: false, + // Strips prefix for the backend + rewrite: (path: string) => path.replace(new RegExp(`^${base.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`), ''), }, }}), },