如何配置我的 firebase 配置以访问 firebase 模拟器功能端点?
How can I configure my firebase config to access the firebase emulator functions endpoint?
先决条件:
- Firebase SDK:^7.21.1
我想将我的 Vue.js 前端与我的本地 firebase 函数模拟器连接。模拟器位于 localhost:5001
。我很难弄清楚必须设置哪些配置属性才能访问模拟器端点。
这是我当前的配置:
const firebaseConfig = {
apiKey: "AIzaSyCKvB9ZluNGOP4s4r8igflwuK-9WVsoThg",
authDomain: "company-29f5c.firebaseapp.com",
databaseURL: "https://company-29f5c.firebaseio.com",
projectId: "company-bar",
storageBucket: "company-29f5c.appspot.com",
messagingSenderId: "1051704079600",
appId: "1:1051704079600:web:f99d362c43b87346",
notificationWebhookUrl: "http://localhost:5001/company-dev/us-central1/notificationsMixpanelWebhook",
cloudFunctionBaseUrl: "http://localhost:5001/company-dev/us-central1",
};
我开始更改 cloudFunctionBaseUrl
,因为使用此 属性 更改函数端点 url 对我来说很明显。如您所见,我将其设置为 localhost:5001/...
。然而,我的应用程序中使用的 url 仍然调用此 url:
https://us-central1-company-bar.cloudfunctions.net
我发现 url 是由配置的 projectId
属性 组成的。 cloudFunctionBaseUrl
因此根本不会覆盖它。
我现在如何更改组合 url
https://us-central1-company-bar.cloudfunctions.net
至
http://localhost:5001/company-dev/us-central1
我希望有某种配置标志,如 enableEmulator
或类似的东西,但在文档中找不到任何提示。
你认为有一个函数是正确的,它叫做 useEmulator
。据我所知,您必须为要模拟的 firebase 的每个部分调用它。
如果你想让函数使用模拟器,你可以执行如下操作:
firebase.functions().useEmulator('localhost', 5001);
firebase.initializeApp
调用后。
更多信息可以在官方文档中找到:https://firebase.google.com/docs/emulator-suite/connect_functions#
先决条件:
- Firebase SDK:^7.21.1
我想将我的 Vue.js 前端与我的本地 firebase 函数模拟器连接。模拟器位于 localhost:5001
。我很难弄清楚必须设置哪些配置属性才能访问模拟器端点。
这是我当前的配置:
const firebaseConfig = {
apiKey: "AIzaSyCKvB9ZluNGOP4s4r8igflwuK-9WVsoThg",
authDomain: "company-29f5c.firebaseapp.com",
databaseURL: "https://company-29f5c.firebaseio.com",
projectId: "company-bar",
storageBucket: "company-29f5c.appspot.com",
messagingSenderId: "1051704079600",
appId: "1:1051704079600:web:f99d362c43b87346",
notificationWebhookUrl: "http://localhost:5001/company-dev/us-central1/notificationsMixpanelWebhook",
cloudFunctionBaseUrl: "http://localhost:5001/company-dev/us-central1",
};
我开始更改 cloudFunctionBaseUrl
,因为使用此 属性 更改函数端点 url 对我来说很明显。如您所见,我将其设置为 localhost:5001/...
。然而,我的应用程序中使用的 url 仍然调用此 url:
https://us-central1-company-bar.cloudfunctions.net
我发现 url 是由配置的 projectId
属性 组成的。 cloudFunctionBaseUrl
因此根本不会覆盖它。
我现在如何更改组合 url
https://us-central1-company-bar.cloudfunctions.net
至
http://localhost:5001/company-dev/us-central1
我希望有某种配置标志,如 enableEmulator
或类似的东西,但在文档中找不到任何提示。
你认为有一个函数是正确的,它叫做 useEmulator
。据我所知,您必须为要模拟的 firebase 的每个部分调用它。
如果你想让函数使用模拟器,你可以执行如下操作:
firebase.functions().useEmulator('localhost', 5001);
firebase.initializeApp
调用后。
更多信息可以在官方文档中找到:https://firebase.google.com/docs/emulator-suite/connect_functions#