【问题标题】:hosting multiple sites in firebase with dynamic content在 Firebase 中托管多个具有动态内容的站点
【发布时间】:2019-12-10 01:57:52
【问题描述】:

Firebase 托管多个具有动态内容的网站。下面的文件我正在使用基于目标的托管到其中一个站点。但有些是如何失败的。

将目标应用到网站的命令

target:apply hosting target-name target-site

部署命令

firebase 部署 --only 托管:目标名称

firebase.json

{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ],
    "source": "functions"
  },
  "hosting": {
    "public": "public",
    "target": "target-name",
    "rewrites": [
       {
        "source": "/**",
        "function": "function"
      }
    ]
  }
}

错误日志:

> [2019-08-02T08:02:33.699Z]
> ---------------------------------------------------------------------- [2019-08-02T08:02:33.703Z] Command:      
> /home/johndoe/.nvm/v10.9.0/bin/node
> /home/johndoe/.nvm/v10.9.0/bin/firebase deploy --only
> hosting:target-name --debug [2019-08-02T08:02:33.703Z] CLI Version:  
> 6.4.0 [2019-08-02T08:02:33.703Z] Platform:      linux [2019-08-02T08:02:33.703Z] Node Version:  v10.9.0
> [2019-08-02T08:02:33.704Z] Time:          Fri Aug 02 2019 13:32:33
> GMT+0530 (India Standard Time) [2019-08-02T08:02:33.704Z]
> ----------------------------------------------------------------------
> 
> [2019-08-02T08:02:33.712Z] > command requires scopes:
> ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
> [2019-08-02T08:02:33.713Z] > authorizing via signed-in user
> [2019-08-02T08:02:33.713Z] [iam] checking project first for
> permissions ["firebase.projects.get","firebasehosting.sites.update"]
> [2019-08-02T08:02:33.718Z] >>> HTTP REQUEST POST
> https://cloudresourcemanager.googleapis.com/v1/projects/first:testIamPermissions
> permissions=[firebase.projects.get, firebasehosting.sites.update]
> [2019-08-02T08:02:35.337Z] <<< HTTP RESPONSE 200
> content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
> Origin,Accept-Encoding, date=Fri, 02 Aug 2019 08:05:56 GMT,
> server=ESF, cache-control=private, x-xss-protection=0,
> x-frame-options=SAMEORIGIN, x-content-type-options=nosniff,
> server-timing=gfet4t7; dur=1407, alt-svc=quic=":443"; ma=2592000;
> v="46,43,39", accept-ranges=none, transfer-encoding=chunked
> [2019-08-02T08:02:35.340Z] >>> HTTP REQUEST GET
> https://firebase.googleapis.com/v1beta1/projects/first   
> [2019-08-02T08:02:35.816Z] <<< HTTP RESPONSE 200
> content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
> Origin,Accept-Encoding, date=Fri, 02 Aug 2019 08:05:57 GMT,
> server=ESF, cache-control=private, x-xss-protection=0,
> x-frame-options=SAMEORIGIN, x-content-type-options=nosniff,
> alt-svc=quic=":443"; ma=2592000; v="46,43,39", accept-ranges=none,
> transfer-encoding=chunked [2019-08-02T08:02:38.550Z] TypeError: Cannot
> read property 'deploys' of undefined
>     at /home/prateekk/.nvm/v10.9.0/lib/node_modules/firebase-tools/lib/deploy/index.js:88:36
>     at process._tickCallback (internal/process/next_tick.js:68:7)

教程

【问题讨论】:

  • 你能提供更多的调试日志吗?
  • 用调试日志更新了问题
  • @MichaelBleigh 你能检查一下,如果我遗漏了什么

标签: firebase firebase-hosting


【解决方案1】:

经过大量挖掘。最后它对我有用。下面是我的 firebase.json 结构。

使用数组结构进行托管并运行“firebase init hosting”- 重置 firebase.json

firebase.json

{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ],
    "source": "functions"
  },
  "hosting": [{
    "public": "public",
    "target": "target-name",
    "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
    ],
    "rewrites": [
       {
        "source": "/**",
        "function": "function"
      }
    ]
  }]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-25
    • 2017-09-20
    • 2019-02-08
    • 2019-12-01
    • 2014-03-31
    • 2011-05-02
    • 2020-01-31
    相关资源
    最近更新 更多