FIles aren't public to the server in express (node.js)


Not being able to link other files, favicons etc when using express.js and node.js. The files are not public to the server. The console shows a 404 error when trying to link any other file.


In express and node, no file is public to the server unless you tell it to.

This is how –

app.use(express.static(__dirname + "dir"));

I recommend putting it all in a seperate folder and make the folder public.

Answered By – potato

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published