为什么Firebase服务可以正常运行,而Firebase无法部署?

时间:2020-06-02 21:13:18

标签: reactjs firebase hosting

我有一个我要部署到firebase的react项目,在firebase serve时可以正常工作,但是我得到类似的信息,因为您已经成功设置了Firebase Hosting,所以看到了这一点。现在该开始构建非凡的东西了! firebase deploy之后,
为什么会这样?

1 个答案:

答案 0 :(得分:0)

答案:我发现了问题。 firebase.json文件已从更改

  "hosting": {
    "public": "build",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ],
  }
}

对此

  "hosting": {
    "public": "build",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ],
    "headers": [{ "source": "/service-worker.js", "headers": [{ "key": "Cache-Control", "value": "no-cache" }] }]
  }
}

它起作用了,有关更多参考, https://create-react-app.dev/docs/deployment/