1

https://evrcare.co/.well-known/assetlinks.json的响应是 [] 而不是有效的 json。
我已将正确的assetlinks.json文件放入.well-known文件夹中。现在发生的事情是我的 TWA 显示一个 url 栏(如果https://evrcare.co/.well-known/assetlinks.json的响应是正确的 json
,则不应该这样 )。 但是,如果我放入其他文件夹而不是类似的文件夹,我可以看到完整的 json:https ://evrcare.co/well-known/assetlinks.json
assetlinks.json.well-known

所以我上网查了一下,他们提出了几种方法,但都没有奏效。喜欢:

1)创建另一个文件夹 well-known并放置assetlinks.json然后重定向:

firebase.json:

 {
        "source": "/.well-known/assetlinks.json",
        "destination": "/well-known/assetlinks.json"
      }

没用。回复: []

2)添加标题application/json**/.well-known/**

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
  }
],

没用。回复: []


您可以使用我当前的配置测试https://evrcare.co/.well-known/assetlinks.jsonhttps://evrcare.co/well-known/assetlinks.json :firebase.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 和 assetslinks.json 文件。

firebase 工具: 8.0.2

平台:视窗


有效 JSON 示例:https ://google.com/.well-known/assetlinks.json

验证链接的工具:

4

1 回答 1

0

我很笨。我的构建工具(jekyll)忽略了以点开头的文件夹。

必须将其添加到我_config.yml的才能使其工作:

# Folders with dotfiles are ignored by default.
include: [.well-known]
于 2020-04-22T19:47:59.393 回答