为什么 firebase 服务工作正常但不是 firebase 部署?

why is firebase serve working fine but not firebase deploy?

我有一个要部署到 firebase 的 React 项目,它在 firebase serve 时工作正常但我得到类似 你看到这个是因为你已经成功设置了 Firebase 托管.现在是时候去建造一些非凡的东西了!firebase deploy 之后,
为什么会这样?

答:我找到问题了。 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/