Firebase托管未显示正确的文件内容

时间:2019-02-27 23:59:56

标签: firebase google-play progressive-web-apps firebase-hosting

我正在尝试在Firebase上托管PWA的assetlinks.json文件,问题是我无法查看该文件的内容。我认为这与我的firebase.json文件有关。我试图获得的链接是 https://bionomichealth.com/.well-known/assetlinks.json 它包含:

    [
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "xyz.appmaker.flvhwm",
      "sha256_cert_fingerprints": ["83:AE:08:45:58:C6:08:16:69:1E:80:50:31:84:1E:B9:55:AF:CC:4F:A9:20:B3:D5:58:B1:6A:D1:E1:27:B3:F7"]
    }
  }
]

最后是我的filebase.json:

    {
  "database": {
    "rules": "database.rules.json"
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ]
  },
  "hosting": {
    "public": "public",
    "rewrites": [
      {
        "source": "/.well-known/assetlinks.json",
        "destination": "assets/assetlinks.json"
      },
      {
        "source": "/public/**",
        "destination": "/public.html"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ],
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
  },
  "storage": {
    "rules": "storage.rules"
  }
}

如您所见,我的资产文件夹中有我的assetlink.json。当我导航到文件时,我得到的是:

[ ]

当我尝试将pwa部署到Playstore时,由于Google认为我不是pwa的所有者,所以收到了暂停通知。

任何帮助将不胜感激。 非常感谢你!

1 个答案:

答案 0 :(得分:0)

所以我也遇到了同样的问题,事实证明,您不需要重写,只需在构建应用程序后将其放在.dist-文件夹下的.well-knwon下。 示例还包含ios文件

{
  "hosting": {
    "target": "main", 
    "public": "dist",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**/apple-app-site-association",
        "destination": "/.well-known/apple-app-site-association"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ],
    "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"
        }]
      }
    ]
  }
}

ios需要重写的原因是因为它们在执行get调用时未附加.json,而且它们要求响应的标头必须为content-type:application / json