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

225
Vistas
Serve different asset paths based on express js

I have a set of routes on express which are brands. Id like to serve 2 asset directories to each of these brands. One public/static for all brand routes and then everything thats under public/brands/brandName.

Is this possible ? I have something like this which seems to work but only for the first /brandName i request.

var express = require('express');
var app = express();
var path = require('path');

app.get('/brands/:brand', function (req, res) {

  app.use(express.static(path.join(__dirname, 'public/brands/' + req.params.brand)));

  res.sendFile(__dirname + '/public/static/index.html');
});

app.listen(process.env.PORT || 3000, function () {
  console.log('listening on port 3000!');
});

app.use(express.static(path.join(__dirname, 'public/static')));

module.exports = app;
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This should do the trick;

app.use('/brands', express.static(path.join(__dirname, 'public/brands/')));
app.use('/static', express.static(path.join(__dirname, 'public/static/')));

app.get('/brands/:brand', function (req, res) {
    res.sendFile(__dirname + '/public/static/index.html');
});
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