gothinkster / react-redux-realworld-example-app

Exemplary real world application built with React + Redux
https://react-redux.realworld.io
MIT License
5.55k stars 2.5k forks source link

Error while serving. ENOENT: no such file or directory when URL is hit directly. 404 Not Found #108

Closed BalasubramaniM closed 2 years ago

BalasubramaniM commented 6 years ago

Error while serving /home/ubuntu/my-app/source/build/login with content-type text/plain : ENOENT: no such file or directory, open '/home/ubuntu/my-app/source/build/login'

I have just cloned this repo and installed the app in my Amazon EC2 instance. Here goes my PM2 configuration file.

module.exports = { apps: [ { name: "my-app", env: { PORT: 3000, NODE_ENV: "production" } } ], deploy: { production: { user: "ubuntu", host: "ec2-xx-xxx-xxx-xx.us-east-2.compute.amazonaws.com", key: "~/.ssh/AWS-EC2-INSTANCE-LIVE.pem", ref: "origin/master", repo: "git@github.com:gothinkster/react-redux-realworld-example-app.git", path: "/home/ubuntu/my-app", "post-deploy": "npm install && npm run build && pm2 serve build 3000" } } };

And here goes my Package.json file script.

"scripts": { "build": "react-scripts build" }

And once my build is compiled successfully, I am serving the static build folder using

pm2 serve build 3000

The site loads successfully. But when I hit the Url like https://my-app.com/login directly in the browser, I get the error 404 Not Found.

But I see no error while navigating. This issue occurs only when hitting any component URL directly or while refreshing from other than a home page.

What am I missing? Thank you.

jasonhtpham commented 2 years ago

I am facing the same issue. Were you able to solve this?

BalasubramaniM commented 2 years ago

I don't remember this anymore @jasonhtpham so closing this.