reactjs - 出现 404-Page Not Found 错误,当我重新加载 Firebase 上的 React 应用程序时

标签 reactjs firebase firebase-hosting

我已经在 firebase 上部署了我的 React 应用程序,当我重新加载页面时,它显示了下面的页面。
enter image description here

Firebase.json

{
  "hosting": {
    "public": "build",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
  }
}

不是单页应用程序

最佳答案

添加以下内容 rewrites规则:

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

这将确保 Firebase 为您请求的任何路由提供您的 React 应用程序。

关于reactjs - 出现 404-Page Not Found 错误,当我重新加载 Firebase 上的 React 应用程序时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61819746/

相关文章:

reactjs - 健全的草稿预览不适用于 block 内容

ios - 如何从最新到最旧的顺序从 Firebase 获取图像?

firebase - 类 'QueryDocumentSnapshot' 没有实例方法 '[]' 。接收器 : Instance of 'QueryDocumentSnapshot' Tried calling: [] ("name")

angular - ng-build 上的端口和代理配置

google-chrome - 当从 Firebase 提供服务时,带有范围请求路由器的 Workbox 预缓存音频无法在 Chrome 中播放

reactjs - 获取React组件的类型propTypes定义

javascript - React 中未找到 Meteor 方法 (404)

javascript - 在自定义 React hook 中使用 fetch - 数据获取两次

ios - firebase身份验证监听器和网络连接

Firebase 托管 ssl 证书显示不同的域