使用 firebase 托管时出现空动态 link assetlinks.json 问题
Empty dynamic link assetlinks.json issue when using firebase hosting
https://evrcare.co/.well-known/assetlinks.json 的响应即将到来 [] 而不是有效的 json。
我已将正确的 assetlinks.json
文件放入 .well-known
文件夹。
现在发生的是我的 TWA 显示了一个 url 条(如果 https://evrcare.co/.well-known/assetlinks.json 的响应是正确的 json,则不应该显示)。
但是,如果我将 assetlinks.json
放在 .well-known
以外的其他文件夹中,我可以看到完整的 json,例如:https://evrcare.co/well-known/assetlinks.json
所以我查看了互联网,他们提出了几种方法,none 其中有效。
喜欢:
1) 创建另一个文件夹well-known
并放入assetlinks.json
然后重定向:
firebase.json:
{
"source": "/.well-known/assetlinks.json",
"destination": "/well-known/assetlinks.json"
}
没有成功。回应:[]
2) 为 **/.well-known/**
添加 header 作为 application/json
firebase.json:
"headers": [
{
"key": "Cache-Control",
"value": "no-store"
},
{
"key": "Expires",
"value": "0"
},
{
"key": "Pragma",
"value": "no-cache"
}
]
},
{
"source": "**/.well-known/**",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
]
}
]
没有成功。响应[]
3) 将 "appAssociation": "NONE"
添加到 firebase.json。
没有成功。我找不到页面。
4) 添加 "dynamicLinks": true 到 "rewrites"
firebase.json:
"rewrites": [
{
"source": "/**",
"dynamicLinks": true
}
],
没有成功。回应:[]
您可以使用我当前的 firebase.json
配置测试 https://evrcare.co/.well-known/assetlinks.json 和 https://evrcare.co/well-known/assetlinks.json:
{
"hosting": {
"public": "_site",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "/bigben",
"function": "bigben"
},
{
"source": "**",
"destination": "/index.html"
},
{
"source": "/.well-known/assetlinks.json",
"destination": "/well-known/assetlinks.json"
}
],
"cleanUrls": true,
"headers": [
{
"source": "**",
"headers": [
{
"key": "Cache-Control",
"value": "no-store"
},
{
"key": "Expires",
"value": "0"
},
{
"key": "Pragma",
"value": "no-cache"
}
]
},
{
"source": "**/.well-known/**",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
]
}
]
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
},
"emulators": {
"functions": {
"port": 5001
},
"firestore": {
"port": 8080
},
"hosting": {
"port": 5000
}
}
}
我按照 https://appmaker.xyz/pwa-to-apk/ 创建了 TWA 和 assetlinks.json 文件。
firebase-tools: 8.0.2
平台: Windows
有效 JSON 示例:https://google.com/.well-known/assetlinks.json
验证链接的工具:
我很笨。我的构建工具 (jekyll) 忽略了以点开头的文件夹。
必须将此添加到我的 _config.yml
才能使其正常工作:
# Folders with dotfiles are ignored by default.
include: [.well-known]
https://evrcare.co/.well-known/assetlinks.json 的响应即将到来 [] 而不是有效的 json。
我已将正确的 assetlinks.json
文件放入 .well-known
文件夹。
现在发生的是我的 TWA 显示了一个 url 条(如果 https://evrcare.co/.well-known/assetlinks.json 的响应是正确的 json,则不应该显示)。
但是,如果我将 assetlinks.json
放在 .well-known
以外的其他文件夹中,我可以看到完整的 json,例如:https://evrcare.co/well-known/assetlinks.json
所以我查看了互联网,他们提出了几种方法,none 其中有效。 喜欢:
1) 创建另一个文件夹well-known
并放入assetlinks.json
然后重定向:
firebase.json:
{
"source": "/.well-known/assetlinks.json",
"destination": "/well-known/assetlinks.json"
}
没有成功。回应:[]
2) 为 **/.well-known/**
application/json
firebase.json:
"headers": [
{
"key": "Cache-Control",
"value": "no-store"
},
{
"key": "Expires",
"value": "0"
},
{
"key": "Pragma",
"value": "no-cache"
}
]
},
{
"source": "**/.well-known/**",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
]
}
]
没有成功。响应[]
3) 将 "appAssociation": "NONE"
添加到 firebase.json。
没有成功。我找不到页面。
4) 添加 "dynamicLinks": true 到 "rewrites"
firebase.json:
"rewrites": [
{
"source": "/**",
"dynamicLinks": true
}
],
没有成功。回应:[]
您可以使用我当前的 firebase.json
配置测试 https://evrcare.co/.well-known/assetlinks.json 和 https://evrcare.co/well-known/assetlinks.json:
{
"hosting": {
"public": "_site",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "/bigben",
"function": "bigben"
},
{
"source": "**",
"destination": "/index.html"
},
{
"source": "/.well-known/assetlinks.json",
"destination": "/well-known/assetlinks.json"
}
],
"cleanUrls": true,
"headers": [
{
"source": "**",
"headers": [
{
"key": "Cache-Control",
"value": "no-store"
},
{
"key": "Expires",
"value": "0"
},
{
"key": "Pragma",
"value": "no-cache"
}
]
},
{
"source": "**/.well-known/**",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
]
}
]
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
},
"emulators": {
"functions": {
"port": 5001
},
"firestore": {
"port": 8080
},
"hosting": {
"port": 5000
}
}
}
我按照 https://appmaker.xyz/pwa-to-apk/ 创建了 TWA 和 assetlinks.json 文件。
firebase-tools: 8.0.2
平台: Windows
有效 JSON 示例:https://google.com/.well-known/assetlinks.json
验证链接的工具:
我很笨。我的构建工具 (jekyll) 忽略了以点开头的文件夹。
必须将此添加到我的 _config.yml
才能使其正常工作:
# Folders with dotfiles are ignored by default.
include: [.well-known]