首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将firebase主机和firebase函数连接到不同的域名

如何将firebase主机和firebase函数连接到不同的域名
EN

Stack Overflow用户
提问于 2020-02-06 13:32:42
回答 1查看 198关注 0票数 0

在我的例子中,我有三个不同的域

代码语言:javascript
运行
复制
https://www.bilal.ai (bilal.ai) <---- for showcase website firebase hosting

https://app.bilal.ai            <---- for the web app

https://api.bilal.ai            <---- for firebase functions

我所做的:

1)我已经通过this document了,我已经连接了我的web应用程序和一些云功能,比如注册功能,通过在我的firebase仪表板中重写托管方法,app.bilal.ai工作得很好,注册功能也很好。

问题

1)第一个域和展示网站是一个完全不同的项目,它是在一个不同的平台上,但我希望他们都在同一个项目中,如果可能的话

2)到目前为止,我已经看到了连接自定义域名到firebase主机和功能的文档,我已经确定连接了它,但这两个域名都在做同样的事情,这是一个问题,例如,当我转到app.bilal.ai时,它显示了应用程序,当我转到api.bilal.ai时,它也显示了错误的web应用程序,我想要这个域名专门用于后端apis,这是firebase功能,例如登录注册功能

3)类似地,当有人调用api.bilal.ai/login时,它使用登录函数工作,但如果通过app.bilal.ai/login调用相同的api,它也工作,这是错误的,我希望这显示错误

4)通过重写方法,我必须将每个函数分别写在firebase.json文件中,我需要一些**东西来连接所有函数和自定义域,这个问题也是在comment here中提出的

EN

回答 1

Stack Overflow用户

发布于 2020-02-06 15:37:46

如果你在使用Blaze计划,你可以试试Firebase multisite hosting

从文档中:

添加域后,应用目标:

代码语言:javascript
运行
复制
firebase target:apply hosting blog bilal-website
firebase target:apply hosting app bilal-api

定义托管配置:

代码语言:javascript
运行
复制
{
  "hosting": [ {
      "target": "website",  // "blog" is the applied target name for the Hosting site "myapp-blog"
      "public": "website/dist",  // contents of this folder are deployed to the site "myapp-blog"

      // ...
    },
    {
      "target": "api",  // "app" is the applied target name for the Hosting site "myapp-app"
      "public": "api/dist",  // contents of this folder are deployed to the site "myapp-app"

      // ...

      "rewrites": [...]  // You can define specific Hosting configurations for each site
    }
  ]
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60088269

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档