Tom*_*lva 7 dns firebase google-cloud-functions
有没有办法使用自定义域的firebase云功能http钩子.
cloudfunctions的默认网址如下所示:
https://us-central1-my-awesome-app.cloudfunctions.net/ios-oauth/
和
我想让它看起来像这样:
https://myawesomeapp.com/ios-oauth/
我环顾四周,是否有其他人在寻找相同的解决方案,我确实找到了这个:
https://stackoverflow.com/questions/43482224/firebase-cloud-functions-custom-domain
Cra*_*les 19
接受的答案是正确的,我去年创建了这个存储库来演示功能:https : //github.com/cjmyles/firebase-react-express
为了按照https://firebase.google.com/docs/hosting/full-config#rewrites保留 HTML pushState 功能,您可能需要扩展规则以允许所有其他请求通过您的 index.html 页面,这解决了@Boris 在他的回答中面临的问题。
"rewrites": [
{
"source": "/api/**",
"function": "app"
},
{
"source": "!/@(api)/**",
"destination": "/index.html"
}
]
Run Code Online (Sandbox Code Playgroud)
这真的不需要,因为重写规则旨在匹配请求的第一次出现(因此顺序很重要),但这对我有用,因为它允许所有非 API 相关的请求通过。
请注意:在撰写本文时,Firebase 文档指出:Firebase 托管仅在 us-central1 中支持 Cloud Functions。
Tom*_*lva 15
我已经联系了firebase支持以获得有关此问题的答案.我在文档中转发到了这一部分.
https://firebase.google.com/docs/hosting/functions#create_an_http_function_to_your_hosting_site
您可以将自己的域与firebase-cloud-functions一起使用.要做的是使用firebase-hosting.
将自定义函数路由添加到firebase.json
{
"hosting": {
"public": "public",
// Add the following rewrites section *within* "hosting"
"rewrites": [{
"source": "/bigben", "function": "bigben"
}]
}
}
Run Code Online (Sandbox Code Playgroud)部署到firebase
| 归档时间: |
|
| 查看次数: |
3575 次 |
| 最近记录: |