fix: correct path routing for Firebase Hosting rewrites in emulator#200
fix: correct path routing for Firebase Hosting rewrites in emulator#200demolaf wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a Firebase Hosting rewrites example and updates the path-based routing logic in the local server to correctly handle hosting rewrites and direct emulator calls. The review feedback highlights several critical bugs in the path parsing and prefix-stripping logic, particularly when handling deep sub-paths (e.g., /echo/deep/path), which can lead to incorrect function name extraction or lost sub-paths. The reviewer suggests refactoring the routing to match segments against registered function names and using the resolved function name to robustly strip prefixes, alongside adding test coverage for deep sub-paths.
|
CI should pass as soon as this PR firebase/firebase-tools#10588 is shipped in the next firebase-tools release. |
Fixes #175
Fixes request path handling for Firebase Hosting rewrites in the emulator: the old heuristic guessed the function name from segment count, causing handlers to receive the emulator's routing prefix instead of the original client path.
The new routing logic matches registered function names directly against path segments and reconstructs the request with the correct path before dispatching.
Adds unit tests, E2E tests via a new echoPath fixture, and a minimal hosting example.
Dependent on firebase/firebase-tools#10588