Serving Static in Express Node.js

September 8, 2015 1.3k views
MEAN Node.js

i have this in my server.js. It is working fine on my local server. When i try on digitalocean. no images are showing up. I am all new to this. Please help. Thank you.

//Setting Static Files Directory

1 comment
2 Answers

Same problem here. Non of the status files in public are being found. Getting errors in the console in the browser. Any ideas?

  • the path names on server are case sensitive. I changed all back then it works. hope it helps :) good luck!

    • you mean the paths to the css files for example in the templates (I'm using handlebars so the .hbs files)?

Paths are relative to the directory from where you launch your node process.


app.use('/static', express.static(__dirname + '/public'));
Have another answer? Share your knowledge.