0
我无法弄清楚如何反应路由器和高速路由一起工作。反应路由器和快速GET冲突
我有这个
app.get('*', function(req, res) {
res.sendFile(path.resolve(__dirname) + '/server/static/index.html');
});
// routes
const apiRoutes = require('./server/routes/api');
app.use('/api', apiRoutes);
问题是我的API无法使用GET,因为它会重定向到index.html的。如果我删除通配符路由,那么react-router将无法正常工作。
只是改变顺序。首先放置你的'api'路线,然后放上'*'路线 – Panther