【发布时间】:2020-06-30 16:37:15
【问题描述】:
我在云功能中使用打字稿构建了一个动态站点。我还有云函数触发器,每当 Firestore 中的数据发生变化时,相关页面都会重新编译为托管在 firebase 云存储桶中的静态页面。
桶看起来像这样:
gs://[bucketname].appspot.com
/app/index.html
/app/page1.html
/app/page2.html
/uploads/images.webp
...
目前,静态网站通过名为 app 的云功能中的快速应用程序提供服务。这里的问题在于云功能状态。它们并不总是很热,这使得初始加载时间非常慢。
firebase.json
"hosting": {
"public": "public",
"rewrites": [{ "source": "**", "function": "app" }],
}
我想要实现的是让 Firebase 托管指向存储桶中的文件,而不是在云功能中使用快速应用程序。言外之意:
firebase.json
"hosting": {
"public": "public",
"rewrites": [
{ "source": "**/:url", "destination": "[BUCKETURL]/app/:url.html" },
{ "source": "**", "destination": "[BUCKETURL]/app/index.html" }]
}
我的 URL 结构非常简单,它是 domain.com/page-name,我也想保持这种方式,最后不带 .html。任何建议将不胜感激。谢谢
【问题讨论】:
标签: firebase google-cloud-functions google-cloud-storage firebase-storage firebase-hosting