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

233
Vistas
How to serve static files from local directories using nodejs express?

I'm working on a Nodejs project that I will run only on my local computer (OS: Windows 10) and serve images and videos from local directories in computer drives (for example: { c:..\ Or D:.... or E:.... }).

Note: This is my first project using node js.

I've searched for answers but none of them helped me.

What is the problem that I have?

The problem I have is that the app can't read images from local directories and I get this error from the console on google chrome:

Not allowed to load local resources: file:///D:/Media/movies/action/Point Blank/folder.jpg

How can I enable reading from local directories in express node js without the need to run chrome with disabling security commands?

I don't know what is the problem, is it because of the slash or backslash in the URL path? or is there something I need to add in app.js?

Some Code lines from the project:

// Image 

<img src="D:/Media/movies/action/Point Blank/folder.jpg" alt="">

//App.js:

const express = require('express');
const path = require('path');

const app = express();

// Servie Static files
app.use('/assets', express.static('assets'))


app.set('views', [
  path.join(__dirname, '../views'),
  path.join(__dirname, '../views/admin'),
  path.join(__dirname, '../views/admin/categories'),
  path.join(__dirname, '../views/admin/users'),
  path.join(__dirname, '../views/guest'),
  path.join(__dirname, '../views/guest/home'),
  path.join(__dirname, '../views/guest/categories')
]);
app.set('view engine', 'ejs');



app.listen(PORT, () => {
  console.log("app is running in mode:", process.env.NODE_ENV);
});


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