From cd206cea81d9ba1d26ed4181e17f47816194bab8 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Mon, 16 Sep 2024 11:05:11 +0200 Subject: [PATCH] chore: refactor proxy configuration to use headers object --- vite.config.mjs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/vite.config.mjs b/vite.config.mjs index af4ea8f525c..e1e09b05f92 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -17,6 +17,12 @@ const proxyURL = process.env.SERVER_URL ? process.env.SERVER_URL : `${proxyScheme}://${proxyHostname}:${proxyPort}` +const headers = ingressToken + ? { + headers: { cookie: `ingress_session=${ingressToken}` }, + } + : {} + // const proxyWebSocketScheme = process.env.SERVER_SSL ? 'wss' : 'ws' // const proxyWebSocketURL = `${proxyWebSocketScheme}://${proxyHostname}:${proxyPort}` @@ -113,25 +119,19 @@ export default defineConfig(({ mode }) => { ws: true, secure: false, // allow self signed certificates changeOrigin: true, - ...(ingressToken && { - headers: { cookie: `ingress_session=${ingressToken}` }, - }), + ...headers, }, '/health': { target: proxyURL, secure: false, changeOrigin: true, - ...(ingressToken && { - headers: { cookie: `ingress_session=${ingressToken}` }, - }), + ...headers, }, '/api': { target: proxyURL, secure: false, changeOrigin: true, - ...(ingressToken && { - headers: { cookie: `ingress_session=${ingressToken}` }, - }), + ...headers, }, }, },