React URLs are not Accessible

一个人想着一个人 提交于 2019-12-25 01:27:25

问题


hi i've run following command pm2 start process.json on ec2 AWS.

Here is my process.json file

{
  "script": "serve",
  "env": {
    "PM2_SERVE_PATH": './build',
    "PM2_SERVE_PORT": 5000
  }
}

When I run the pm2 command shown above. I can access the Base URL. But when I type the Sub URLs from browser, it shows a page that contains 404 |The requested path cannot be found.

Below is my file structure

I am generating the project using npm run build then pm2 start process.json


回答1:


So the app starts up and you can access the root page? What about your routes? Are they set up properly? Are you using react-routing or something else?

This sounds like a routing issue. Does it only happen on the AWS platform?




回答2:


Hi I found a solution to this problem.

When I use serve on pm2 it shows 404 page whenever it didn't find a url resource. To resolve that I used screen on ec2.

To open a new screen type screen Then in your react folder type command serve -s build -p 5000 Now you can detach your screen using CTRL + D



来源:https://stackoverflow.com/questions/51996232/react-urls-are-not-accessible

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!