【发布时间】:2021-02-16 03:43:59
【问题描述】:
当我重新加载 Heroku 页面时,我收到一个内部服务器错误,状态码为 500。
但这不会发生在我的本地环境中。
最重要的是,
当我访问正确重定向并正常显示的路由地址时。
当我重新加载页面时,在 chrom 开发工具的网络信息中说该页面没有处理任何进程。
我的程序有什么问题?
这是网站。
https://boiling-falls-61617.herokuapp.com/
这是我的错误和代码。
错误
2020-03-15T19:33:53.875586+00:00 heroku[router]: at=info method=GET path="/dashboards/5e6b999eb7f157252c8c6937" host=boiling-falls-61617.herokuapp.com request_id=785b2a93-2739-455f-856e-e59fb5af18ce fwd="99.251.226.61" dyno=web.1 connect=0ms service=2ms status=500 bytes=404 protocol=https
服务器代码
if (process.env.NODE_ENV === "production") {
app.use(express.static(path.join(__dirname, "client", "build")));
app.get("*", (req, res) => {
// don't serve api routes to react app
res.sendFile(path.join(__dirname, "./client/build/index.html"));
});
console.log("Serving React App...");
}
前端
function App() {
return (
<MuiThemeProvider theme={theme}>
<BrowserRouter>
<PrivateRoute path='/dashboards/:dashboardId' component={DashBoard} />
<Route exact path='/' component={SignIn} />
<Route path='/signup' component={SignUp} />
<PrivateRoute
path='/(dashboards|calendar)/:dashboardId/columns/:columnId/tasks/:taskId'
render={props => <CardModal {...props} />}
/>
<Route path='/calendar/:dashboardId' component={Calendar} />
</BrowserRouter>
</MuiThemeProvider>
);
}
【问题讨论】: