在这里反应/反应router/heroku问题(它可能是heroku失败的地方).
我正在关注这个精彩的教程:https://medium.com/@patriciolpezjuri/using-create-react-app-with-react-router-express-js-8fa658bf892d#.y77yjte2j ,一切工作到我发布的地步它到heroku,我尝试导航到https://appname.herokuapp.com/about,我得到404 Not Found/nginx错误.当然,根据教程,它应该显示一个关于页面.
底线:React路由器无法在heroku上工作,我无法弄清楚原因.
我已经尝试修改我的server/app.js文件,如下所示:React路由在facebook的create-react-app构建中不起作用
// server/app.js
const express = require('express');
const morgan = require('morgan');
const path = require('path');
const app = express();
console.log('hi from /src/server.js')
// Setup logger
app.use(morgan(':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] :response-time ms'));
// Serve static assets
app.use(express.static(path.resolve(__dirname, '..', 'build')));
// Always return the main index.html, so react-router render the route in the client
app.get('/about', (req, res) => {
console.log('hi from …Run Code Online (Sandbox Code Playgroud)