Node express routing sendfile fails depending on file location Node express routing sendfile fails depending on file location express express

Node express routing sendfile fails depending on file location


Thanks @Joe. For completeness since the dupe isn't very clear and trying various relative pathing including trying {root: 'somepath'} as 2nd param didn't work this is what I did:

var path = require('path');...app.get('*', function(req, res) {    res.sendfile(path.resolve('public/index.html'));});

Even though that is in the lib/ directory it resolved using the base directory, to re-reiterate relative resolving didn't work for me but there may be some way of doing it.