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.mdSTART 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