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

252
Vistas
Set nodejs project directory based on the URL

I am currently serving angular1 application over node js app. I want to serve my angular1 app as well as angular2 app from same domain with this node server. I have following setting in my app.js of node js file:

var staticDir = nodeEnv == 'development' ? path.join(__dirname, '/home/sovf/ang1/') : '/data/project/angular/app';

My angular1 project directory is here: /home/sovf/ang1/ My angular2 project directory is here: /home/svof/ang2/

How can I configure the staticDir to use '/home/svof/ang2/' , when the url matches /ang2/*

I have tried enogh to look for resources and node configuration for this but could not find anything. Can any one please help here.

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

0

You can create a new instance of express.static that uses /home/svof/ang2 as root directory (where it should look for the static resources), and "mount" that instance on /ang2, so it will only match requests that start with that prefix:

app.use('/ang2', express.static(path.join(__dirname, '/home/svof/ang2')));
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