我正在使用Firebase后端开发一个项目,利用Firebase功能。我实际上是两个项目: myProject
和 myproject-test
(用于部署测试)。
提交API调用时,将我的(REECT)前端配置为在本地开发中运行时调用 myProject-test
url,并且仅将调用转到 myProject
时在产品上。
我面临的问题是,当我开始使用 firebase模拟器启动云函数模拟器时:start
,我的云功能在 localhost:5001/myproject /......上开始。 URL代替 localhost:5001/myproject-test /... ,因此我本地开发实例中的API呼叫永远不会到达。
我如何控制模拟器开始的哪个项目?
I am developing a project with Firebase backend, utilising Firebase Functions. I actually two projects: myProject
and myProject-test
(used for deployment testing).
When submitting API calls, my (React) front-end is configured to call the myProject-test
URL when running in local development, and only direct the calls to myProject
when deployed on PROD.
The problem I am facing is that when I start my cloud functions emulator using firebase emulators:start
, my cloud functions get started on the localhost:5001/myProject/...
url instead of localhost:5001/myProject-test/...
, and hence the API calls from my local development instance never arrive.
How can I control for which project the emulators start?
发布评论
评论(1)
这就是
firebase使用
命令的目的。在 firebase使用project_id |别名来设置当前用于模拟器或其他命令的当前项目或别名。This is what the
firebase use
command is for. Read the documentation on managing aliases. You can run the commandfirebase use PROJECT_ID|ALIAS
to set the current project or alias that is currently use use for the emulator or other commands.