Skip to content

fix(hosting): route Cloud Run rewrites to local functions emulator#10588

Open
demolaf wants to merge 2 commits into
mainfrom
fix/cloud-run-proxy-emulator
Open

fix(hosting): route Cloud Run rewrites to local functions emulator#10588
demolaf wants to merge 2 commits into
mainfrom
fix/cloud-run-proxy-emulator

Conversation

@demolaf
Copy link
Copy Markdown
Member

@demolaf demolaf commented Jun 2, 2026

When using Firebase Hosting rewrites with "run" format (required for Dart/Cloud Run functions),
the hosting emulator always hit the live Cloud Run API to resolve the service URL — even when the
functions emulator was running locally. This caused an error like:

Error looking up URL for Cloud Run service: 404, Resource 'app' does not exist

Fix

Add emulator detection to cloudRunProxy.ts, mirroring the existing logic in functionsProxy.ts.
When targets includes "functions" and the functions emulator is running, route directly to the
local emulator URL instead of calling the Cloud Run API.

Related firebase/firebase-functions-dart#200

@demolaf demolaf marked this pull request as draft June 2, 2026 22:17
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for routing Cloud Run rewrites to the local functions emulator when 'functions' is specified in the targets and the emulator is running. The review feedback suggests optimizing the implementation by replacing lodash dependencies (includes and cloneDeep) with native TypeScript features, such as optional chaining with Array.prototype.includes and standard object spreading, which allows for the removal of the external lodash imports.

Comment thread src/hosting/cloudRunProxy.ts Outdated
Comment thread src/hosting/cloudRunProxy.ts Outdated
Comment thread src/hosting/cloudRunProxy.spec.ts Outdated
Comment thread src/hosting/cloudRunProxy.spec.ts Outdated
Comment thread src/hosting/cloudRunProxy.spec.ts Outdated
@demolaf demolaf force-pushed the fix/cloud-run-proxy-emulator branch from 6095037 to 1dff63b Compare June 3, 2026 08:31
@demolaf demolaf marked this pull request as ready for review June 3, 2026 08:33
@demolaf demolaf requested review from Lyokone and ajperel June 3, 2026 08:33
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