Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

596
Views
404 Not Found static files React JS | NGINX

I want to make my site available on a domain without port 3000, I know that React JS and Nginx cannot use the same ports, so below you can see the configuration of my Nginx file:

location / {
   # try_files $uri $uri.html $uri/ @extensionless-php;
     proxy_set_header Accept-Encoding "";
     proxy_pass http://localhost:3000;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection 'upgrade';
     proxy_set_header Host $host;
     proxy_cache_bypass $http_upgrade;
}

location /static/ {
     proxy_set_header Accept-Encoding "";
     proxy_pass http://localhost:3000;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection 'upgrade';
     proxy_set_header Host $host;
     proxy_cache_bypass $http_upgrade;
}

When I go to https://example.com I see a blank page and the following errors in the console: Image

But when I go to http://example.com:3000 it all works without any issues, so how can I make it work on https://example.com?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

From your description, I assume you are running the react app using npm run start/yarn start, which is intended for your development environment. Running the app on your server, however, brings it to "production".

Running npm run build/yarn build gives you all your source files in a compiled and optimized format. You can put them on your server and let them be served by nginx right away (like using the try_files) without the need for running a separate server or passing the request as a proxy.

If you would like to run your app only as a proxy anyway (e.g. it’s your dev environment), you have to fix the paths in your nginx config, because your /static/ location does not forward to the proxys /static/ path. You can do so by either adding the path to proxy_pass or by removing the complete second location block — it will be equivalent to the first one.

For your reference:

  • https://create-react-app.dev/docs/production-build/
  • https://blog.devgenius.io/using-nginx-to-serve-react-application-static-vs-proxy-69b85f368e6c
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!