firebase - Firebase 动态链接 — 根 URL
问题描述
我正在使用Firebase 动态链接将用户重定向到移动应用。
链接喜欢的https://example.com/mypath
作品,但我也想使用根网址,即https://example.com
目前它显示错误:
无效的动态链接
请求的 URL ( https://example.com/ ) 必须是可解析且完整的 DynamicLink。
如果您是此应用的开发者,请确保您的动态链接域配置正确并且此 URL 的路径组件有效。
当我尝试设置没有前缀的链接时,它显示错误:
短网址为必填项
有没有办法设置root url?
解决方案
从根动态链接域设置重定向的另一种方法(不提供带有 javascript 重定向的页面)是在 firebase.json 文件中添加类似这样的重定向规则:
"redirects": [ {
"source": "/",
"destination": "https://example.com/page-for-root-to-redirect-to",
"type": 301
} ]
此规则将与您的动态链接重写规则一起存在,因此对于除根以外的所有路径都被视为动态链接的简单设置,您的 firebase.json 可能如下所示:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [ {
"source": "/**",
"dynamicLinks": true
} ],
"redirects": [ {
"source": "/",
"destination": "https://example.com/page-for-root-to-redirect-to",
"type": 301
} ]
}
}
要访问和修改您的 firebase.json 文件,您必须使用 Firebase CLI 设置 Firebase 托管(如果您还没有):https ://firebase.google.com/docs/hosting
本页解释了有关 firebase.json 文件以及如何使用重写和重定向规则的更多信息:https ://firebase.google.com/docs/hosting/full-config
推荐阅读
- html - 组件使用 setState Hook 无法正确重新渲染
- python - PyQt QListView 复选框单击切换?
- awk - 从包含多组基因坐标的文件中提取一组基因坐标
- mule - 无法将自定义 Mule 连接器部署到 Anypoint Exchange
- git - 如何仅针对某个目录从“他们的”分支中接受 git 合并冲突?
- algorithm - 哪些技术可以有效地找到任意数据点的周期性?
- python - 如何使用 Scrapy 退回多件商品?
- javascript - ChartJS 不显示时间序列条形图的数据
- android - WebView 未加载 Url,因为 Canvas:试图绘制太大(...)位图
- sql - 如何更新表中的数据以将结果存储在另一个表中