From 1d32d6eec3adce61fb41be2069ff048e324a6fe5 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Sun, 2 Mar 2025 05:13:23 +0000 Subject: [PATCH] use PUBLIC_URL in prod --- packages/appview/src/auth/client.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/appview/src/auth/client.ts b/packages/appview/src/auth/client.ts index 2f9d6a3..df857a6 100644 --- a/packages/appview/src/auth/client.ts +++ b/packages/appview/src/auth/client.ts @@ -8,7 +8,7 @@ export const createClient = async (db: Database) => { // Get the ngrok URL from environment variables const ngrokUrl = env.NGROK_URL - if (!ngrokUrl) { + if (!ngrokUrl && env.NODE_ENV === 'development') { console.warn( 'WARNING: NGROK_URL is not set. OAuth login might not work properly.', ) @@ -16,10 +16,11 @@ export const createClient = async (db: Database) => { 'You should run ngrok and set the NGROK_URL environment variable.', ) console.warn('Example: NGROK_URL=https://abcd-123-45-678-90.ngrok.io') + } else if (env.NODE_ENV === 'production' && !env.PUBLIC_URL) { + throw new Error('PUBLIC_URL is not set') } - // The base URL is either the ngrok URL (preferred) or a local URL as fallback - const baseUrl = ngrokUrl || `http://127.0.0.1:${env.PORT}` + const baseUrl = ngrokUrl || env.PUBLIC_URL || `http://127.0.0.1:${env.PORT}` return new NodeOAuthClient({ clientMetadata: { -- 2.51.2