[cloud_functions]: Apple platforms ignore custom domains passed as region

未关闭 适合新手
#19,015 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

@ragavendranbala-TSL 已经在做这个了。

开始于 2026年11月27日。

  • #19016 来自 @ragavendranbala-TSL —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
dart, ios, macos, swift

调研方向

从 iOS 和 macOS 共用的 FirebaseFunctionsPlugin.swift 开始,跟踪参数 region 如何传递到 Functions.functions(app:region:)。将该调用与 iOS/macOS SDK 的工厂方法 Functions.functions(app:customDomain:),以及 issue 中描述的 Android 和 Web 处理方式进行比较。完成标准是:在 Apple 平台上,自定义域名 URL 会传递给自定义域名工厂方法,而普通的 region 值仍使用 region 工厂方法。

由索引模型根据 Issue 内容生成。

描述

Needs Attention platform: ios platform: macos plugin: functions type: bug

[cloud_functions]: Apple platforms ignore custom domains passed as region

Which plugins are affected?

Functions

Which platforms are affected?

iOS, macOS

Description

The Android and web Firebase SDKs accept a custom domain in the same
parameter as a region — regionOrCustomDomain. On Android,
FirebaseFunctions.getInstance(app, regionOrCustomDomain) URL-parses the
value and switches to custom-domain mode when it is a URL; the JS SDK's
getFunctions(app, regionOrCustomDomain) does the same.

The Firebase iOS/macOS SDKs also support custom domains, but through a
separate factory: Functions.functions(app:customDomain:). When a custom
domain string is passed to Functions.functions(app:region:) instead, the
SDK interpolates it into the host and produces a malformed URL such as
https://https://example.com-project.cloudfunctions.net/name.

The Flutter plugin always calls Functions.functions(app:region:) and
never exposes the customDomain: factory, so on Apple platforms there is
no way to reach a function through a custom domain — for example a
Google Cloud Load Balancer fronting Cloud Armor, where the function must
be called at https://api.example.com/functionName rather than the
cloudfunctions.net host.

Reproducing the issue

  1. Deploy a callable function behind a custom domain.
  2. Call FirebaseFunctions.instanceFor(region: 'https://api.example.com').httpsCallable('myFunction').call().
  3. On Android and web the call reaches the custom domain. On iOS/macOS it
    fails: the plugin passes the URL string as a region, and the SDK builds
    an invalid cloudfunctions.net URL.

Suggested fix

In FirebaseFunctionsPlugin.swift (shared by iOS and macOS), detect an
http prefix in the region argument and call
Functions.functions(app:customDomain:) instead — matching the
region-or-custom-domain convention the other SDKs already use. This adds
no public Dart API surface.

主要语言
Dart
星标
9.3k
派生
4.1k
平均合并
4 天 17 小时
30 天内合并 PR
49

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/flutterfire 的其他 Issue

查看 firebase/flutterfire 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。