Skip to content

Add findings and plan for Firebase Local Emulator Suite in local dev#342

Open
HarmlessHarm wants to merge 3 commits into
mainfrom
claude/firebase-emulator-investigation-ownbts
Open

Add findings and plan for Firebase Local Emulator Suite in local dev#342
HarmlessHarm wants to merge 3 commits into
mainfrom
claude/firebase-emulator-investigation-ownbts

Conversation

@HarmlessHarm

Copy link
Copy Markdown
Collaborator

Investigation of replacing the online-Firebase dependency during local
development with the Firebase Local Emulator Suite (Auth, RTDB, Storage),
including required env vars, proposed emulator config, conditional
useEmulator() wiring points for client SDK and firebase-admin, and known
blockers (service account file read at SSR startup, external HK content API).

https://claude.ai/code/session_0143398zobwdf7EVfSh84iS6

claude added 3 commits June 12, 2026 22:35
Investigation of replacing the online-Firebase dependency during local
development with the Firebase Local Emulator Suite (Auth, RTDB, Storage),
including required env vars, proposed emulator config, conditional
useEmulator() wiring points for client SDK and firebase-admin, and known
blockers (service account file read at SSR startup, external HK content API).

https://claude.ai/code/session_0143398zobwdf7EVfSh84iS6
Lets the app run fully offline against the Firebase Emulator Suite (Auth,
RTDB, Storage) with permissive local-only rules and no real credentials,
while prd/acc/dev keep using real Firebase untouched.

- firebase.emulator.json + emulator/ rules (open .read/.write, local only)
- .env.emulator with demo- dummy config; env.js resolves it when
  USE_FIREBASE_EMULATOR=true or when no .env.<NODE_ENV>.local exists
- conditional useEmulator() wiring in src/firebase.js (client + SSR)
- conditional firebase-admin init in src-ssr/api/index.js; the service
  account file is now read only in non-emulator mode, fixing a dev-server
  startup crash when the key file is absent
- emulators / ssr:emulator npm scripts + firebase-tools devDependency

Verified end-to-end: emulators boot, SSR homepage renders (200), auth
routes redirect, and an Auth-emulator token is accepted by the admin SDK
which then reads RTDB - all with no real credentials.
Browser sign-in failed with auth/network-request-failed because the
useEmulator() calls used "localhost": on dual-stack machines localhost
resolves to IPv6 ::1 first, but the emulators bind IPv4 only, so the
browser could not reach the Auth emulator. Pin client useEmulator() hosts
and the admin FIREBASE_*_EMULATOR_HOST vars to 127.0.0.1.

Verified via firebase emulators:exec: email/password signUp + signIn both
return 200 with an idToken, and RTDB read/write succeed on 127.0.0.1.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants