To fix the deployment error and ensure your app works correctly in AWS Amplify, you need to configure these environment variables in your Amplify console.
NEXT_PUBLIC_FB_API_KEY=AIzaSyA4SlE_cvI6Ed-M2tDqDrEfXNKcYhH4NEY
NEXT_PUBLIC_FB_AUTH_DOMAIN=interviewtraker.firebaseapp.com
NEXT_PUBLIC_FB_PROJECT_ID=interviewtraker
NEXT_PUBLIC_FB_STORAGE=interviewtraker.firebasestorage.app
NEXT_PUBLIC_SITE_DOMAIN=interview-king.taobowen.com
NEXT_PUBLIC_FB_STORAGE_BUCKET=interviewtraker.appspot.com
FIREBASE_SERVICE_ACCOUNT_KEY={"type":"service_account","project_id":"interviewtraker","private_key_id":"...your complete service account JSON as single line..."}
DATABASE_URL=postgresql://username:password@host:port/database?schema=public
- Environment Variables are set in Amplify Console → App Settings → Environment Variables
- During Build: The
amplify.ymlautomatically writes these to.env.production - At Runtime: Next.js SSR can read environment variables from
.env.production
The build configuration in amplify.yml automatically:
- Installs dependencies with
npm ci - Creates
.env.productionwith all required environment variables - Runs
npm run buildwhich includes Prisma generation - Caches build artifacts for faster deployments
- Open your AWS Amplify Console
- Navigate to your app
- Go to "App Settings" > "Environment Variables"
- Click "Manage variables"
- Add each variable one by one:
- Variable name:
FIREBASE_SERVICE_ACCOUNT_KEY - Value: Your complete Firebase service account JSON (as a single line string)
- Click "Add variable"
- Repeat for
DATABASE_URLand other variables
- Variable name:
- Go to Firebase Console
- Select your project (
interviewtraker) - Go to Project Settings (gear icon)
- Navigate to Service Accounts tab
- Click Generate New Private Key
- Download the JSON file
- Copy the entire JSON content as a single line (no line breaks)
- Use this as the value for
FIREBASE_SERVICE_ACCOUNT_KEY
⚠️ Never commit the service account key to Git⚠️ The JSON must be on a single line (no line breaks or formatting)- ✅ All NEXT_PUBLIC_ variables are safe to commit* (they're public)
- ✅ After adding variables, redeploy your app in Amplify
- Trigger a new deployment in AWS Amplify
- Check build logs to ensure no more environment variable errors
- Test your deployed app to verify Firebase authentication works