···88 // Get the ngrok URL from environment variables
99 const ngrokUrl = env.NGROK_URL
10101111- if (!ngrokUrl) {
1111+ if (!ngrokUrl && env.NODE_ENV === 'development') {
1212 console.warn(
1313 'WARNING: NGROK_URL is not set. OAuth login might not work properly.',
1414 )
···1616 'You should run ngrok and set the NGROK_URL environment variable.',
1717 )
1818 console.warn('Example: NGROK_URL=https://abcd-123-45-678-90.ngrok.io')
1919+ } else if (env.NODE_ENV === 'production' && !env.PUBLIC_URL) {
2020+ throw new Error('PUBLIC_URL is not set')
1921 }
20222121- // The base URL is either the ngrok URL (preferred) or a local URL as fallback
2222- const baseUrl = ngrokUrl || `http://127.0.0.1:${env.PORT}`
2323+ const baseUrl = ngrokUrl || env.PUBLIC_URL || `http://127.0.0.1:${env.PORT}`
23242425 return new NodeOAuthClient({
2526 clientMetadata: {