From 1e9042036c2203b229785bf3f036f66cc21b790a Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Sun, 30 Nov 2025 17:33:26 -0800 Subject: [PATCH] fix(frontend): update env vars for dev --- frontend/.env | 3 ++- .../packages/components/src/lib/config.ts | 10 ++------- frontend/src/components/lib/config.ts | 10 ++------- frontend/src/lib/env.ts | 6 ++---- pnpm-lock.yaml | 21 +++++++++++++++++-- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/frontend/.env b/frontend/.env index aff66ac0f9..195dbc717d 100644 --- a/frontend/.env +++ b/frontend/.env @@ -1,11 +1,12 @@ VITE_APP_API_URL=http://localhost:43708/api +VITE_APP_CLOUD_API_URL=http://localhost:43708/api VITE_APP_ASSETS_URL=https://assets2.rivet.gg +VITE_APP_CLERK_PUBLISHABLE_KEY=pk_test_Zmlyc3QtZG9ua2V5LTQuY2xlcmsuYWNjb3VudHMuZGV2JA VITE_APP_SENTRY_DSN="https://66a566505cfb4341732a3d350f2b87e2@o4504307129188352.ingest.sentry.io/4506435887366144" VITE_APP_SENTRY_PROJECT_ID="4506435887366144" # This is a public-facing token, safe to commit to repo VITE_APP_POSTHOG_API_KEY=phc_6kfTNEAVw7rn1LA51cO3D69FefbKupSWFaM7OUgEpEo VITE_APP_POSTHOG_HOST=https://ph.rivet.gg -VITE_APP_CLOUD_API_URL=https://cloud.rivet.gg/api DEPLOYMENT_TYPE=staging # Overridden in CI diff --git a/frontend/packages/components/src/lib/config.ts b/frontend/packages/components/src/lib/config.ts index bd02d6e968..1a1d76d0c5 100644 --- a/frontend/packages/components/src/lib/config.ts +++ b/frontend/packages/components/src/lib/config.ts @@ -25,14 +25,8 @@ export const useConfig = () => useContext(ConfigContext); export const ConfigProvider = ConfigContext.Provider; const getApiEndpoint = (apiEndpoint: string) => { - if (apiEndpoint === "__AUTO__") { - if (location.hostname.startsWith("hub.")) { - // Connect to the corresponding API endpoint - return `https://${location.hostname.replace("hub.", "api.")}`; - } - // Default to staging servers for all other endpoints - return "https://api.staging2.gameinc.io"; - } else if (apiEndpoint === "__SAME__") { + // __SAME__ is used in Docker builds to serve API from the same origin as the frontend + if (apiEndpoint === "__SAME__") { return location.origin; } return apiEndpoint; diff --git a/frontend/src/components/lib/config.ts b/frontend/src/components/lib/config.ts index b4702f10dc..aae7f54658 100644 --- a/frontend/src/components/lib/config.ts +++ b/frontend/src/components/lib/config.ts @@ -24,14 +24,8 @@ export const useConfig = () => useContext(ConfigContext); export const ConfigProvider = ConfigContext.Provider; export const getApiEndpoint = (apiEndpoint: string) => { - if (typeof window !== "undefined" && apiEndpoint === "__AUTO__") { - if (window.location.hostname.startsWith("hub.")) { - // Connect to the corresponding API endpoint - return `https://${window.location.hostname.replace("hub.", "api.")}`; - } - // Default to staging servers for all other endpoints - return "https://api.staging2.gameinc.io"; - } else if (typeof window !== "undefined" && apiEndpoint === "__SAME__") { + // __SAME__ is used in Docker builds to serve API from the same origin as the frontend + if (typeof window !== "undefined" && apiEndpoint === "__SAME__") { return window.location.origin; } return apiEndpoint; diff --git a/frontend/src/lib/env.ts b/frontend/src/lib/env.ts index b7f734d63a..20e984b4f9 100644 --- a/frontend/src/lib/env.ts +++ b/frontend/src/lib/env.ts @@ -2,6 +2,7 @@ import z from "zod"; import { getApiEndpoint } from "../components/lib/config"; export const commonEnvSchema = z.object({ + // Engine API endpoint - transformed via getApiEndpoint() for local development support VITE_APP_API_URL: z.string().transform((url) => { return getApiEndpoint(url); }), @@ -23,10 +24,7 @@ export const engineEnv = () => commonEnvSchema.parse(import.meta.env); export const cloudEnvSchema = commonEnvSchema.merge( z.object({ - VITE_APP_API_URL: z.string().transform((url) => { - return getApiEndpoint(url); - }), - VITE_APP_CLOUD_ENGINE_URL: z.string().url(), + // Cloud API endpoint - direct URL without transformation, used for cloud-specific operations VITE_APP_CLOUD_API_URL: z.string().url(), VITE_APP_CLERK_PUBLISHABLE_KEY: z.string(), }), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0fb9605a36..500a09418c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1637,8 +1637,8 @@ importers: specifier: ^1.2.3 version: 1.2.3(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.1.1(react@19.1.1))(react@19.1.1) '@rivet-gg/cloud': - specifier: https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@bf2ebb2 - version: https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@bf2ebb2 + specifier: https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@1fcfb72 + version: https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@1fcfb72 '@rivet-gg/icons': specifier: workspace:* version: link:packages/icons @@ -6417,6 +6417,10 @@ packages: '@rivet-gg/api@25.5.3': resolution: {integrity: sha512-pj8xYQ+I/aQDbThmicPxvR+TWAzGoLSE53mbJi4QZHF8VH2oMvU7CMWqy7OTFH30DIRyVzsnHHRJZKGwtmQL3g==} + '@rivet-gg/cloud@https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@1fcfb72': + resolution: {tarball: https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@1fcfb72} + version: 0.0.0 + '@rivet-gg/cloud@https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@bf2ebb2': resolution: {tarball: https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@bf2ebb2} version: 0.0.0 @@ -18259,6 +18263,19 @@ snapshots: transitivePeerDependencies: - encoding + '@rivet-gg/cloud@https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@1fcfb72': + dependencies: + cross-fetch: 4.1.0 + form-data: 4.0.5 + js-base64: 3.7.8 + node-fetch: 2.7.0 + pino-pretty: 13.1.2 + qs: 6.14.0 + readable-stream: 4.7.0 + url-join: 5.0.0 + transitivePeerDependencies: + - encoding + '@rivet-gg/cloud@https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@bf2ebb2': dependencies: cross-fetch: 4.1.0