Express 允许expess通过路由对路由器作出反应

Express 允许expess通过路由对路由器作出反应,express,reactjs,react-router,Express,Reactjs,React Router,我正在使用一个快速网页包react/react路由器应用程序(^2.0.0-rc5)。在express中,我使用的是app.use(express.static(path.join(uu dirname,'dist'))将我的react应用程序映射到url 当我转到http://localhost:3001/在我的应用程序中,它导航良好。然后当我点击一个按钮链接时,'ing指向http://localhost:3001/diff-放置,它将导航到新页面 但是,当我直接进入http://local

我正在使用一个快速网页包react/react路由器应用程序(^2.0.0-rc5)。在express中,我使用的是app.use(express.static(path.join(uu dirname,'dist'))将我的react应用程序映射到url

当我转到
http://localhost:3001/
在我的应用程序中,它导航良好。然后当我点击一个按钮
链接时,
'ing指向
http://localhost:3001/diff-放置
,它将导航到新页面

但是,当我直接进入
http://localhost:3001/diff-放置
,express拦截请求并发出404


我不知道如何解决这一问题,因此任何建议都将不胜感激

在express routes的末尾,请确保定义了一个将为任何页面请求加载客户端的全面路由,并确保将示例中的index.html替换为html入口点。在这一点上,路由器将启动

app.get('*', function(req, res) {
  res.sendFile(path.resolve(__dirname + 'dist/index.html'));
});