MongoDB Configuration
MONGODB_URI
Required
OpenAI Configuration
OPENAI_API_KEY
Required
- Sign up at OpenAI Platform
- Navigate to API keys section
- Create a new API key
- Ensure you have sufficient credits
OPENAI_BASE_URL
Optional - Defaults to
https://api.openai.com/v1OPENAI_MODEL
Optional - Defaults to
gpt-4o-minigpt-4ogpt-4-turbogpt-3.5-turbo
NextAuth Configuration
NEXTAUTH_URL
Required
NEXTAUTH_SECRET
Required
- Minimum 32 characters
- Use cryptographically random characters
- Keep this secret and never commit to version control
SecondMe OAuth
SECONDME_CLIENT_ID
Required
- Register your application in the SecondMe developer console
- Copy the Client ID
- Configure callback URL:
https://<your-domain>/api/auth/callback
SECONDME_CLIENT_SECRET
Required
- Keep this value secret
- Never commit to version control
- Rotate regularly for security
GitHub OAuth
GITHUB_ID
Required
- Go to GitHub Settings > Developer settings > OAuth Apps
- Create a new OAuth App
- Set callback URL:
https://<your-domain>/api/auth/callback/github - Copy the Client ID
GITHUB_SECRET
Required
- In your GitHub OAuth App settings
- Generate a new client secret
- Copy and save immediately (it won’t be shown again)
Google OAuth
GOOGLE_CLIENT_ID
Required
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
https://<your-domain>/api/auth/callback/google - Copy the Client ID
GOOGLE_CLIENT_SECRET
Required
- Found in the same credentials section as the Client ID
- Download the JSON file for safekeeping
Optional Configuration
MIGRATION_ADMIN_IDS
Optional
- Granting specific users access to administrative functions
- Running database migrations
- Managing system-level operations
Environment-Specific Configuration
Development (.env.local)
Production (Vercel)
Security Best Practices
Checklist
- All required variables are set
- Secrets are randomly generated and secure
-
.env.localis in.gitignore - Production and development use different OAuth apps
-
NEXTAUTH_URLmatches your actual domain - MongoDB network access is properly configured
- OpenAI API key has sufficient credits
Troubleshooting
Missing environment variable errors
Missing environment variable errors
If you see errors about missing environment variables:
- Check that all required variables are set
- Verify variable names match exactly (case-sensitive)
- In Vercel, ensure variables are assigned to correct environments
- Redeploy after adding new variables
OAuth configuration issues
OAuth configuration issues
If OAuth login fails:
- Verify callback URLs match
NEXTAUTH_URL+ the provider’s callback path - Check that OAuth credentials are for the correct environment
- Ensure secrets are copied completely without extra spaces
- Clear browser cookies and try again
Database connection failures
Database connection failures
If MongoDB connection fails:
- Test connection string format
- Verify user credentials are correct
- Check network access settings in MongoDB Atlas
- Ensure database name exists in the connection string