This application uses Firebase for authentication and database storage.
The previous implementation faced issues with the Firebase Admin SDK token expiration:
Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim.
This was caused by:
- System time being incorrectly set (detected as April 12, 2025, which is in the future)
- Firebase Admin SDK's JWT tokens require system time to be accurate within 60 minutes
We've implemented a hybrid approach:
- Firebase Client SDK - Used for all Firestore operations (read/write data)
- Custom User Creation - Implemented a client-side user creation function that mimics the Admin SDK's interface
- No JWT Tokens - Eliminated dependency on system-time-sensitive tokens
For this implementation to work, you must update your Firestore security rules in the Firebase Console to:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /Users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
allow create: if request.resource.data.email != null;
}
}
}
Required environment variables:
FIREBASE_PROJECT_ID
: Your Firebase project IDFIREBASE_API_KEY
: Web API Key from Firebase consoleFIREBASE_MESSAGING_SENDER_ID
: Firebase messaging sender IDFIREBASE_APP_ID
: Firebase application ID