Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

598
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda