fix(frontend/vite): Configure vite dev proxy to handle frontend path
This commit is contained in:
parent
7710e2549e
commit
57e2a33dc6
|
|
@ -269,16 +269,25 @@ function getBuildConfig(env: Record<string, string>) {
|
|||
function getServeConfig(env: Record<string, string>) {
|
||||
// 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, '\\$&')}`), ''),
|
||||
},
|
||||
}}),
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue