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

155
Vistas
express.static() cannot get favicon and files without index.html in build folder

express can't find static files in build folder. express can serve files in static folder now. but only problem that file path likes <link rel="icon" href="/favicon.ico"/> in index.html it reach res.send('ERROR')

however, when I change favicon and manifest path like <link rel="icon" href="/assets/favicon.ico"/>. it serve file I expected.

  • add : I found that if url is localhost//favicon.ico, can access favicon.ico in build folder. (not in assets). only double slash can access build folder, single slash cannot access that. Is my express startpoint localhost/ not localhost?
    server  
    |-server.js
    |-build  
      |-static  
        |-assets  
          |-favicon.ico
          |-manifest.json
        |-index.html  
        |-favicon.ico  
        |-manifest.json  
   
    localhost => return index.html good  
    localhost/index.html, favicon.ico, else... => return ERROR  
    localhost/assets/favicon.ico, manifest.json => return files good
    localhost//index.html, favicon.ico. else... => return files good  
    app.use('/static', express.static(path.join(__dirname, 'build/static')));
    app.use(express.static(path.join(__dirname, 'build')));
    app.use('/*', (req, res) => res.send('ERROR');
about 4 years ago · Juan Pablo Isaza
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