Add findings and plan for Firebase Local Emulator Suite in local dev#342
Open
HarmlessHarm wants to merge 3 commits into
Open
Add findings and plan for Firebase Local Emulator Suite in local dev#342HarmlessHarm wants to merge 3 commits into
HarmlessHarm wants to merge 3 commits into
Conversation
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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