Completed creation of application and updated to production. Users should be able to register and use app but having trouble with registration confirmation email and password retrieval email. The link sent to user emails points to localhost error website rather than live production website
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
Vercel Alum
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://)"