【发布时间】:2020-03-19 07:05:39
【问题描述】:
我正在使用 create-react-app,它在我的本地运行良好,完全没有问题。当我将它部署在 IBM Cloud 上时,登录后,当我刷新页面时,它给出 404 not found 错误它之前工作正常,不知道发生了什么。
我看到了很多相关的问题,我试图解决但没有工作的事情如下
1. 创建了一个static.json
{
"root": "build/",
"routes": {
"/**": "index.html"
}
}
2。我有这个设置
devServer: {
historyApiFallback: true,
contentBase: './',
hot: true
},
3.我尝试在路由器周围添加,没有用
import React, { Component } from 'react';
import styled from 'styled-components';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
class App extends Component {
render() {
return (
<>
<Router>
<Switch>
<Route exact path="/" component={SignUp} />
<Route path="/some" component={Some} />
</Switch>
</Router>
</>
);
}
}
export default App;
4.我尝试添加以下内容
import { HashRouter } from 'react-router-dom'
<HashRouter>
<App/>
</HashRouter>
这些似乎都不适合我。任何建议
【问题讨论】:
标签: javascript reactjs nginx ibm-cloud create-react-app