Skip to content

๐ŸŽ‰ 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.md with 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.local file
  • Configuring Cloudflare Pages
  • Testing your first deployment

Time: ~20 minutes

2. Install Firebase SDK โ€‹

bash
npm install firebase

3. Create Your Local Environment File โ€‹

bash
cp .env.local.example .env.local
# Then edit .env.local with your Firebase dev config

How It Works โ€‹

Local Development โ€‹

bash
npm run dev
  • Runs on localhost:5173
  • Uses .env.local (your dev Firebase project)
  • No deployment, just local testing

Development Environment (Staging) โ€‹

bash
git push origin dev
  • Auto-deploys to Cloudflare preview URL
  • Uses dev Firebase project
  • Accessible to team for testing

Production Environment โ€‹

bash
git push origin main
  • Auto-deploys to production URL
  • Uses production Firebase project
  • Live for users

Environment Separation โ€‹

EnvironmentGit BranchURLFirebase ProjectConfig Source
LocalN/Alocalhost:5173dev.env.local
Dev/Stagingdev*.pages.dev (preview)devCloudflare Preview vars
Productionmain*.pages.dev (production)prodCloudflare 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 โ€‹

bash
# 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 dist

Troubleshooting โ€‹

"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 โ€‹

  1. Quick setup (20 min): ENVIRONMENT_SETUP.md
  2. Full reference: DEPLOYMENT.md
  3. Firebase details: TECHSTACK.md

Ready to start? โ†’ Open docs/engineering/ENVIRONMENT_SETUP.md and follow Step 1! ๐Ÿš€

Built with VitePress