【发布时间】:2021-09-13 17:06:39
【问题描述】:
我有一个使用 React.js 的网站,部署在 AWS EC2 实例上。
为了部署它,我使用 Bitbucket 管道系统。
作为服务器,我使用 NGINX。
我的问题是:要使用屏幕之间的导航,我应该在 NGINX 配置文件中设置一些东西吗?因为如果我尝试使用“链接到”,例如转到主页,我的网址就会变成
http://IP.compute-1.amazonaws.com/register 但结果是 404 未找到
编辑:路由器:
<BrowserRouter>
<Switch>
<Route path="/home" component={Home} exact/>
<Route path="/profile" component={Profile}/>
<Route path="/" component={Login}/>
<Route path="/register" component={Register}/>
<Route component={Error}/>
</Switch>
</BrowserRouter>
导航:
<Link to="/register">
<button className="loginRegisterButton">
Create a New Account
</button>
</Link>
给出“404 not found nginx”的路径:
http://ec2-***-**-**-**.compute-1.amazonaws.com/home
另外,我认为在 NGINX 上我没有我需要的所有文件: 在家庭/ec2 用户中: screenshot
【问题讨论】:
-
很高兴您找到了解决问题的方法。但是,实际的答案/解决方案应该不被编辑到您的问题中。一般来说,您应该edit 来澄清这个问题,但不要在其中包含答案。您应该使用用于解决问题的代码/解决方案创建自己的答案,然后接受它(系统可能需要 48 小时延迟才能这样做)。当你自己解决了问题时,answering your own question is encouraged。
标签: reactjs nginx amazon-ec2 bitbucket-pipelines