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

166
Vistas
Is it good practice to run a backend and a frontend server with express in NodeJS?

I am currently working on a simple NodeJS/AngularJS application and my current project looks like this:

/frontend/index.html <-- AngularJS home page
/frontend/js/app.js  <-- AngularJS app.js
/backend/package.json<-- NodeJS package.json
/backend/index.js    <-- NodeJS script

and I am only serving the backend API with my NodeJS express server while I open the frontend part directly (file://.../frontend/index.html) in my browser.

Is it good practice to serve both the "Backend API" and the frontend with NodeJS (e.g. with two express instances running) and how would I organize the code?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

while I open the frontend part directly (file://.../frontend/index.html) in my browser.

That is something you can only do on your own local computer. You cannot do that for a regular web server that other people can use. So, that is NOT considered a viable practice for a regular web server designed for other people on the internet to use.

With one line of code using express.static() middleware you can have your existing node.js server also serve all your static HTML files. You do not need a separate process for serving the HTML files. At super large scale, you might use something like an NGINX proxy to serve your static HTML files, but I don't see any reason for you to be going that direction now. At this point, just have your existing node.js server use express.static() to serve your static files and stop using any file:// references.

Is it good practice to serve both the "Backend API" and the frontend with NodeJS (e.g. with two express instances running) and how would I organize the code?

No. You've shown no reason why you would need two node.js instances. Just use the one instance to serve both the API and the static HTML files.

about 4 years ago · Santiago Trujillo 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