在 npm run build 之后,我使用命令 http-server build 启动http服务器。服务器工作正常,我可以浏览页面,但是每当我开始刷新页面或通过URL访问它时,都会出现404错误。
[Tue Jul 31 2018 10:26:12 GMT+0300 (Eastern European Summer Time)] "GET /key-word-mapping" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36"
[Tue Jul 31 2018 10:26:12 GMT+0300 (Eastern European Summer Time)] "GET /key-word-mapping" Error (404): "Not found"
使用 npm start 时没有出现此问题。有办法解决这个问题吗?
我在路由器上使用ReactJS来浏览页面。
这是我的App.js:
class App extends React.Component<{}> {
render(): React.Node {
return (
<LocaleProvider locale={enUS}>
<Router>
<Switch>
<Route path="/signin" component={SigninPage} />
<PrivateRoute exact path="/" component={ResultsPage} />
<PrivateRoute path="/key-word-mapping" component={WordMappingPage} />
<PrivateRoute path="/words" component={WordsPage} />
<PrivateRoute path="/mapped-seniority" component={MappedSeniority} />
<PrivateRoute path="/mapped-department" component={MappedDepartment} />
</Switch>
</Router>
</LocaleProvider>
);
}
}