From 2aef5d4b1a59c8029f6b963d96dc4540ed9f1781 Mon Sep 17 00:00:00 2001 From: Bilal Godil Date: Thu, 18 Jun 2026 17:00:48 -0700 Subject: [PATCH] Inject HEXCLAVE_* env vars in dev environment `envVarsForProject` only emitted the legacy STACK_* names, while the rest of the CLI (init, doctor, resolveProjectId) uses HEXCLAVE_* as the canonical brand with STACK_* as a fallback. Emit both brands so `hexclave dev` matches that convention. STACK_* output is unchanged and the secret server key is still never exposed under a public framework prefix. --- .../remote-development-environment/manager.ts | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/apps/dashboard/src/lib/remote-development-environment/manager.ts b/apps/dashboard/src/lib/remote-development-environment/manager.ts index 9c18cc7bf..1de2ad4ac 100644 --- a/apps/dashboard/src/lib/remote-development-environment/manager.ts +++ b/apps/dashboard/src/lib/remote-development-environment/manager.ts @@ -219,21 +219,30 @@ function createInternalApp(apiBaseUrl: string, anonymousRefreshToken?: string) { } function envVarsForProject(project: RemoteDevelopmentEnvironmentProject): Record { - return { - STACK_PROJECT_ID: project.projectId, - NEXT_PUBLIC_STACK_PROJECT_ID: project.projectId, - VITE_STACK_PROJECT_ID: project.projectId, - EXPO_PUBLIC_STACK_PROJECT_ID: project.projectId, - STACK_PUBLISHABLE_CLIENT_KEY: project.publishableClientKey, - NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY: project.publishableClientKey, - VITE_STACK_PUBLISHABLE_CLIENT_KEY: project.publishableClientKey, - EXPO_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY: project.publishableClientKey, - STACK_SECRET_SERVER_KEY: project.secretServerKey, - STACK_API_URL: project.apiBaseUrl, - NEXT_PUBLIC_STACK_API_URL: project.apiBaseUrl, - VITE_STACK_API_URL: project.apiBaseUrl, - EXPO_PUBLIC_STACK_API_URL: project.apiBaseUrl, + const brands = ["HEXCLAVE", "STACK"]; + const publicPrefixes = ["", "NEXT_PUBLIC_", "VITE_", "EXPO_PUBLIC_"]; + + const publicValues: Record = { + PROJECT_ID: project.projectId, + PUBLISHABLE_CLIENT_KEY: project.publishableClientKey, + API_URL: project.apiBaseUrl, }; + const secretValues: Record = { + SECRET_SERVER_KEY: project.secretServerKey, + }; + + const env: Record = {}; + for (const brand of brands) { + for (const [name, value] of Object.entries(publicValues)) { + for (const prefix of publicPrefixes) { + env[`${prefix}${brand}_${name}`] = value; + } + } + for (const [name, value] of Object.entries(secretValues)) { + env[`${brand}_${name}`] = value; + } + } + return env; } async function getOrCreateProject(options: {