firebase - Firebase 将多个子域托管到具有 1 个项目的应用目录
问题描述
我目前有一个部署到 Firebase 托管的应用程序,其结构如下:
public/
appSub1/
index.html
appSub2
index.html
index.html
我已经添加并连接了我的子域,这样
appSub1.mysite.com/ -> app.firebaseapp.com/
appSub2.mysite.com/ -> app.firebaseapp.com/
我正在尝试配置重定向以将子域与正确的应用程序子文件夹正确关联,以便
appSub1.mysite.com/ -> app.firebaseapp.com/appSub1/
appSub2.mysite.com/ -> app.firebaseapp.com/appSub2/
如果我手动添加子路径,应用程序仍然可以正确显示,但没有它们。所以会以appSub1.mysite.com/
空白页结束,但会以appSub1.mysite.com/appSub1/
正确的方式结束index.html
这是我当前的托管配置firebase.json
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "appSub1.mysite.com/**",
"destination": "/appSub1/**",
"type": 301
},
{
"source": "appSub2.mysite.com/**",
"destination": "/appSub2/**",
"type": 301
}
]
},
解决方案
我推荐以下内容:
- 在 Firebase 上升级到 Blaze 计划
- 使用 Firebase 多站点托管方法(参考:https ://firebase.google.com/docs/hosting/multisites )
- 分成两个单独的托管项目目标 - 比如说
public/app1
和- 因此,默认情况下托管地址将是和(或者现在截至 2019 年 5 月,您还将获得一个域 -public/app2
app1
app2
app1.firebaseapp.com
app2.firebaseapp.com
.web.app
app1.web.app
- 通过在域注册表上配置 DNS 条目来连接各个子域(请参阅:https ://medium.com/@fransandi/use-firebase-multisite-hosting-to-associate-multiple-domains-subdomains-to-your-project-ee099109bfe9 )
推荐阅读
- sql - 有没有办法用变量 N 获得 NTH_VALUE?(SQL - 大查询)
- sql - 讨厌的 sql 错误(POSTGRES)“没有唯一约束匹配给定键的引用表......”
- bluetooth - 写入描述符失败 - HM-10 BLE
- youtube - 在 SwiftUI 视图中嵌入 Youtube 视频?
- python - pandas rolling apply on a custom function
- python - 扫描字符串文字语法错误时 EOL
- jquery - Add dynamic class to element
- kubernetes - kubernetes expose services with Traefik 2.x as ingress with CRD
- java - 使用@Inject 注解注入 Dao 类的问题
- tfs - 从目标服务器触发发布管道