React URLs are not Accessible
Asked Answered
R

2

0

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

enter image description here

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

Run answered 24/8, 2018 at 1:16 Comment(0)
R
0

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

Run answered 17/12, 2018 at 5:10 Comment(0)
O
0

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?

Ontology answered 25/8, 2018 at 10:22 Comment(1)
I can access the base url. But other urls are not accessible. It shows 404 error message. I use react router. yeah it only happens on AWS PlatformRun
R
0

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

Run answered 17/12, 2018 at 5:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.