From 65ce046c8e43814d392f235fc7fc30050a63fbd7 Mon Sep 17 00:00:00 2001 From: Skylar Date: Thu, 19 Sep 2024 11:50:22 -0700 Subject: [PATCH] feat: frontend uses relative API path (#34) --- kontrol-frontend/.env.dev | 8 +++----- kontrol-frontend/.env.production | 2 +- kontrol-frontend/vite.config.ts | 7 ++++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/kontrol-frontend/.env.dev b/kontrol-frontend/.env.dev index f8fe657..26eec97 100644 --- a/kontrol-frontend/.env.dev +++ b/kontrol-frontend/.env.dev @@ -1,5 +1,3 @@ -# default: use local kontrol API -VITE_API_URL=http://localhost:8080 - -# uncomment to use production kontrol API proxy locally -# VITE_API_URL=http://localhost:5173/api +# default: use local kontrol API. +# To use production API, change the proxy target in vite.config.ts +VITE_API_URL=/api diff --git a/kontrol-frontend/.env.production b/kontrol-frontend/.env.production index b7e4023..e82c617 100644 --- a/kontrol-frontend/.env.production +++ b/kontrol-frontend/.env.production @@ -1 +1 @@ -VITE_API_URL=https://app.kardinal.dev/api +VITE_API_URL=/api diff --git a/kontrol-frontend/vite.config.ts b/kontrol-frontend/vite.config.ts index d78b3a3..1e4daec 100644 --- a/kontrol-frontend/vite.config.ts +++ b/kontrol-frontend/vite.config.ts @@ -14,9 +14,14 @@ export default defineConfig(({ mode }) => { }, server: { proxy: { + // local dev mode proxy, default is local kontrol service. + // change this to hit production etc if desired. + // in production, this behavior is handled by kardinal nginx ingress "/api": { - target: "https://app.kardinal.dev", + // target: "https://app.kardinal.dev", + target: "http://localhost:8080", changeOrigin: true, + rewrite: (path) => path.replace(/^\/api/, ""), }, }, },