Troubleshooting
Quick links: Frontend • Backend
Backend
Common issues:
-
Missing
FIREBASE_SERVICE_ACCOUNT_BASE64- Symptoms: Admin SDK init fails in API routes. Use
/api/debug-env.
- Symptoms: Admin SDK init fails in API routes. Use
-
Stripe webhook signature verification fails
- Ensure raw body is read and
STRIPE_WEBHOOK_SECRETmatches dashboard.
- Ensure raw body is read and
-
OAuth callback URL mismatch
- Verify provider dashboards use exact callback URL from Functions config.
-
Billing portal returns "No Stripe customer for user"
- Ensure
users/{uid}.stripeCustomerIdis set during verify-session.
- Ensure
-
Storage upload CORS/preflight fails (status 403/404/0 on
firebasestorage.googleapis.com)- Ensure the correct bucket name is used in env
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET. - Apply CORS to the bucket with
gsutil cors set path/to/cors.json gs://<bucket>using the user-created config described in Setup → Firebase; the checked-incors.jsonis only an example template. - Confirm Firebase Auth → Authorized domains includes your web origins.
- Ensure the correct bucket name is used in env
API Error Debugging
- Error Logs: Check
errorLogscollection in Firestore for detailed error tracking - Request Tracking: Use
X-Request-IDheader to correlate requests across logs - Development Mode: Set
NODE_ENV=developmentfor detailed error responses with stack traces - Error Codes: Reference the API Error Handling documentation for error code meanings
Diagnostics:
- Check Next.js server logs and Firebase Functions logs.
- Log
event.typefor unhandled Stripe events to refine webhook handling.
Related frontend: see Frontend
Frontend
- After sign-in, ensure the client posts the ID token to
/api/auth/sessionto create__session. - Stripe success page must call
/api/verify-sessionwithsessionIdfrom the URL. - Integration connect buttons should call
startAuth(platform, idToken, window.location.href, isLocal)and then redirect to the returned{ authUrl }.
Related backend: see Backend