Search code examples
node.jsexpressherokustatic-files

express.static not working with heroku


I've got this code:

app.use(express.static(__dirname + '/assets'));

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

    res.sendFile(path.join( __dirname, 'assets', 'index.html' ));
});

But am still getting these errors: enter image description here

Any idea what the heck I'm doing wrong? (of course the files exist in the directory as shown)

Thanks in advance!


Solution

  • If you have a file called ./assets/css/bootstrap.css and you configure express.static so that ./assets/ is the root directory, the URL should be /css/bootstrap.css.