๐ Environment Setup Complete! โ
Your dev/production environment separation is now fully configured.
What Was Created โ
Configuration Files โ
- โ
.env.local.exampleโ Template for local development - โ
.env.development.exampleโ Template for Cloudflare preview/dev branch - โ
.env.production.exampleโ Template for Cloudflare production - โ
src/firebase.jsโ Firebase initialization with auto-detection - โ
public/_headersโ Security headers for PWA - โ
public/_redirectsโ SPA routing configuration - โ
wrangler.tomlโ Cloudflare Pages configuration
Documentation โ
- โ
docs/engineering/ENVIRONMENT_SETUP.mdโ START HERE (step-by-step guide) - โ
docs/engineering/DEPLOYMENT.mdโ Complete deployment reference - โ
Updated
docs/DOCS_INDEX.mdwith new links
Updated Files โ
- โ
.gitignoreโ Added environment variable protection
๐ Next Steps (Do This Now!) โ
1. Follow the Environment Setup Guide โ
Open and follow: docs/engineering/ENVIRONMENT_SETUP.md
This guide walks you through:
- Creating Firebase projects (dev + prod)
- Setting up local
.env.localfile - Configuring Cloudflare Pages
- Testing your first deployment
Time: ~20 minutes
2. Install Firebase SDK โ
npm install firebase3. Create Your Local Environment File โ
cp .env.local.example .env.local
# Then edit .env.local with your Firebase dev configHow It Works โ
Local Development โ
npm run dev- Runs on
localhost:5173 - Uses
.env.local(your dev Firebase project) - No deployment, just local testing
Development Environment (Staging) โ
git push origin dev- Auto-deploys to Cloudflare preview URL
- Uses dev Firebase project
- Accessible to team for testing
Production Environment โ
git push origin main- Auto-deploys to production URL
- Uses production Firebase project
- Live for users
Environment Separation โ
| Environment | Git Branch | URL | Firebase Project | Config Source |
|---|---|---|---|---|
| Local | N/A | localhost:5173 | dev | .env.local |
| Dev/Staging | dev | *.pages.dev (preview) | dev | Cloudflare Preview vars |
| Production | main | *.pages.dev (production) | prod | Cloudflare Production vars |
Security Features โ
โ
Environment variables never committed (.gitignore configured) โ
Separate Firebase projects (dev data never touches production) โ
Security headers configured (CSP, X-Frame-Options, etc.) โ
SPA routing works (no 404s on refresh) โ
PWA-ready (service worker headers configured)
Quick Reference โ
Files You'll Edit โ
.env.localโ Your local dev config (create from.env.local.example)- Cloudflare dashboard โ Set environment variables for deployments
Files You Won't Touch โ
.env.*.exampleโ These are templates (committed to git)src/firebase.jsโ Auto-detects environment (no changes needed)
Important Commands โ
# Local development
npm run dev
# Build for production
npm run build
# Preview production build locally
npm run preview
# Deploy manually (alternative to git push)
npx wrangler pages deploy distTroubleshooting โ
"Firebase not initialized" error? โ Check you created .env.local from .env.local.example
Build fails on Cloudflare? โ Make sure you set all environment variables in Cloudflare dashboard
Wrong Firebase project connecting? โ Check environment variables for Production vs Preview in Cloudflare
Need more help? โ See docs/engineering/DEPLOYMENT.md (full guide)
๐ Read the Full Guides โ
- Quick setup (20 min): ENVIRONMENT_SETUP.md
- Full reference: DEPLOYMENT.md
- Firebase details: TECHSTACK.md
Ready to start? โ Open docs/engineering/ENVIRONMENT_SETUP.md and follow Step 1! ๐