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: {