1

I build the react app (which was created using create-react-app) using npm run build command. I added "homepage":"./" to the package.json file and build the project. (But I am not sure what should be written in homepage in the package json file)

Then I copied what was inside build folder to nginx's HTML folder after creating a new folder named 'sample' inside the HTML folder in nginx.

Then in the browser, I opened the URL localhost:81/sample/, but it's not working.

can someone please tell me the step by step process that I should follow to host my react app in nginx

1 Answer 1

1
  • First make sure Nginx is running on your port 8080 (or port 8081 in your case since you are hosting it there). I don't recall I have to add the homepage to package.json file. I just need to do npm run build then copy the build folder to /usr/share/nginx/html/. However, my project is Nginx with React on Docker.
  • What operating system are you using? There is some tutorial showing step by step to host it on Nginx, for example, on Ubuntu: https://medium.com/@timmykko/deploying-create-react-app-with-nginx-and-ubuntu-e6fe83c5e9e7
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.