Hey, @amenyaj-8769!
It sounds like it could be an issue with environment variables. Are you still pointing to your local development environment, by any chance?
I also recommend checking out this thread on how to get good answers from the community:
I have rechecked the enviroment variable and ensured they are all added but still experiencing same issue. Can you look over my environment variables and see if there’s any missing or entered incorrectly?
I am receiving the following messages below, but when I check the variables, these are all present. Is there another place I need to check and update? - I have attached what I have in there
FAILURE: Production environment has critical errors.
Fix all errors before attempting deployment.
Errors:
- Required environment variable NEXT_PUBLIC_APP_URL is missing
- EMAIL_HOST contains localhost in production
Could you try and debug with some logs?
// Add logging to identify the issue
console.log('Auth environment:', {
url: process.env.NEXTAUTH_URL,
hasSecret: !!process.env.NEXTAUTH_SECRET,
environment: process.env.NODE_ENV
});
This is the error that generates when I run the logs:
Check NEXT_PUBLIC_APP_URL issues
if [ -z “$NEXT_PUBLIC_APP_URL” ]; then
echo “
NEXT_PUBLIC_APP_URL is not configured”
if [ “$NODE_ENV” = “production” ]; then
echo “
CRITICAL: This will break authentication in production!”
CRITICAL_ISSUES=$((CRITICAL_ISSUES + 1))
else
echo “
This may cause authentication issues”
WARNINGS=$((WARNINGS + 1))
fi
else
echo “
NEXT_PUBLIC_APP_URL is configured”
# Validate URL format
if [[ "$NEXT_PUBLIC_APP_URL" =~ ^https?:// ]]; then
echo "✅ URL has valid protocol"
# Check for localhost in production
if [ "$NODE_ENV" = "production" ] && [[ "$NEXT_PUBLIC_APP_URL" == *"localhost"* ]]; then
echo "🚨 CRITICAL: Using localhost URL in production!"
echo " 💡 Email callbacks will fail from external email clients"
CRITICAL_ISSUES=$((CRITICAL_ISSUES + 1))
fi
# Check for HTTP in production
if [ "$NODE_ENV" = "production" ] && [[ "$NEXT_PUBLIC_APP_URL" == http://* ]]; then
echo "🚨 CRITICAL: Using HTTP in production!"
echo " 💡 Session cookies will be insecure"
CRITICAL_ISSUES=$((CRITICAL_ISSUES + 1))
fi
# Check for trailing slash
if [[ "$NEXT_PUBLIC_APP_URL" == */ ]]; then
echo "⚠️ URL ends with trailing slash"
echo " 💡 Remove trailing slash for consistency"
WARNINGS=$((WARNINGS + 1))
fi
else
echo "❌ URL missing protocol (http:// or https://)"
CRITICAL_ISSUES=$((CRITICAL_ISSUES + 1))
fi
fi
Check for Vercel environment
if [ ! -z “$VERCEL” ]; then
echo “”
echo “
VERCEL DEPLOYMENT DETECTED:”
echo " VERCEL_ENV: ${VERCEL_ENV:-“Not set”}"
echo " VERCEL_URL: ${VERCEL_URL:-“Not set”}"
if [ "$VERCEL_ENV" = "production" ] && [ -z "$NEXT_PUBLIC_APP_URL" ]; then
echo "🚨 CRITICAL: Production Vercel deployment without NEXT_PUBLIC_APP_URL"
CRITICAL_ISSUES=$((CRITICAL_ISSUES + 1))
fi
fi
Still need support on this issue. I have tried all the suggested solutions but I am not getting it to work.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
