【问题标题】:React-router did not work on productionReact-router 不适用于生产
【发布时间】:2016-08-30 12:56:59
【问题描述】:

那里,

我正在为这个应用程序使用 react-router。它在我的本地服务器上运行良好。代码如下:

var routes = (
 <Router history={browserHistory}>
  <Route path="/" component={App} />
  <Route path="/concepts" component={Concepts} />
  <Route path="/ssdb" component={SolarSystem} />
  <Route path="/missions" component={Missions} />
 </Router>
)

但是,当我使用 webpack 部署到 firebase 服务器时,路由不再起作用。 url 说“这个文件不存在,当前目录下没有 index.html 或者根目录下没有 404.html”。

我错过了什么吗?谢谢!

【问题讨论】:

  • 控制台有错误吗?
  • 没有错误...但我们刚刚发现它是关于火力基地的

标签: reactjs firebase webpack react-router firebase-hosting


【解决方案1】:

事实证明,我们需要将重写添加到 firebase.json。希望它对其他人的类似问题有所帮助。

 "rewrites": [{
    "source": "**",
    "destination": "/index.html"
    }]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-15
    • 2019-12-10
    • 1970-01-01
    • 1970-01-01
    • 2018-11-17
    • 2016-10-26
    • 2019-06-24
    • 2022-01-02
    相关资源
    最近更新 更多