This guide documents the authentication fixes applied to Urbindex and provides comprehensive deployment instructions including automatic deployment via GitHub Actions.
- Old structure: Multiple HTML files (index.html, final.html, etc.)
- New structure: Single
index.htmlas the main entry point - Changes made:
- Backed up old index.html to
index-old-backup.html - Copied fixed
final.htmltoindex.html - All fixes are now in the main
index.htmlfile
- Backed up old index.html to
# Install Firebase CLI globally if not already installed
npm install -g firebase-tools
# Generate a CI token
firebase login:ciCopy the token that is displayed - you'll need it for GitHub Secrets.
Go to your GitHub repository → Settings → Secrets and variables → Actions
Add the following secret:
- Name:
FIREBASE_TOKEN - Value: The token you generated in step 1
The workflow is already configured in .github/workflows/firebase-deploy.yml and will:
- On push to main/master: Deploy to production Firebase Hosting
- On pull request: Deploy to a preview channel for testing
- Automatically deploy Firestore rules
- Comment on PRs with preview URLs
- Make a commit and push to your repository
- Go to the "Actions" tab in GitHub
- Watch the deployment workflow run
- Check for any errors in the logs
- Authentication Flow: Standardized across the application
- UI State Management: FAB button and auth indicators update correctly
- Firestore Permissions: Proper handling of anonymous auth
- Error Handling: Toast notifications instead of alerts
- User Experience: Clear prompts and feedback
// Key improvements in index.html:
- Deferred Firestore queries until after authentication
- Added proper error handling for permission errors
- Implemented toast notification system
- Fixed FAB button visibility logic
- Added authentication checks before operations- Node.js 14+ installed
- Firebase CLI installed (
npm install -g firebase-tools) - Access to the Firebase project
-
Login to Firebase:
firebase login
-
Deploy Everything:
firebase deploy
-
Deploy Specific Services:
# Hosting only firebase deploy --only hosting # Firestore rules only firebase deploy --only firestore:rules # Functions only (if any) firebase deploy --only functions
- Run
test-auth.htmllocally and verify all tests pass - Test authentication flow in
index.html - Verify FAB button shows/hides correctly
- Test adding a location
- Check console for errors
- Visit production URL
- Test sign in/out functionality
- Add a test location
- Verify map loads correctly
- Test on mobile devices
- Check browser console for errors
urbindex/
├── index.html # Main application (with all fixes)
├── index-old-backup.html # Backup of original buggy version
├── test-auth.html # Authentication test suite
├── firebase.json # Firebase configuration
├── firestore.rules # Security rules
├── service-worker.js # PWA offline support
├── manifest.json # PWA manifest
├── .github/
│ └── workflows/
│ └── firebase-deploy.yml # CI/CD workflow
└── docs/
├── AUTHENTICATION_PLAN.md # Future auth improvements
└── DEPLOYMENT_GUIDE.md # This file
{
"hosting": {
"public": ".",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**",
"test-auth.html",
"index-old-backup.html"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{
"source": "**/*.@(jpg|jpeg|gif|png|webp|svg)",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=604800"
}
]
},
{
"source": "**/*.@(js|css)",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=3600"
}
]
}
]
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
}
}- Check GitHub Actions tab for deployment status
- Review deployment logs for any warnings
- Monitor Firebase Console for usage and errors
- Firebase Console → Functions → Logs (if using functions)
- Firebase Console → Hosting → Usage
- Browser DevTools console for client-side errors
- Use Firebase Performance Monitoring
- Check Lighthouse scores regularly
- Monitor load times and user feedback
-
Authentication Error:
- Regenerate Firebase CI token
- Update FIREBASE_TOKEN in GitHub Secrets
-
Build Failures:
- Check syntax errors in files
- Verify all dependencies are committed
-
Deployment Failures:
- Check Firebase project permissions
- Verify project ID matches in workflow
-
"Permission Denied" in app:
- User not authenticated
- Firestore rules not deployed
- Check browser console
-
FAB button not showing:
- Clear browser cache
- Check authentication state
- Verify JavaScript loads
-
Map not loading:
- Check network requests
- Verify Leaflet CDN is accessible
- Check for JavaScript errors
# List recent releases
firebase hosting:releases:list
# Rollback to previous version
firebase hosting:rollback- Revert the GitHub commit
- Push to trigger new deployment
- Or manually deploy previous version
- Firebase CI token
- Firebase API keys (though they're public-facing)
- Any service account keys
- Regular security audits
- Monitor for unusual activity
- Keep dependencies updated
- Review Firestore rules regularly
-
Immediate:
- Push code to GitHub to trigger deployment
- Monitor first automatic deployment
- Test production site thoroughly
-
Short-term:
- Implement email authentication (see AUTHENTICATION_PLAN.md)
- Add error tracking (Sentry/Bugsnag)
- Set up monitoring alerts
-
Long-term:
- Social authentication
- User profiles enhancement
- Performance optimization
- Firebase Documentation: https://firebase.google.com/docs
- GitHub Actions: https://docs.github.com/en/actions
- Project Issues: File in GitHub repository
- Authentication Roadmap: See AUTHENTICATION_PLAN.md
Version: 2.0
Last Updated: December 2024
Status: Production Ready with CI/CD