I'm serving a 404 page with Express:
server.use(function(req, res, next) {
res.status(404).sendFile('404.html', { root: __dirname + BASE })
})
The 404.html
is located in the website's root, and everything work flawlessly if I try to open a non-existent page on the root
(http://mywebsite.com/asd
).
Problem is when I try to open a page inside other folders (http://mywebsite.com/asd/asd
). The paths for my css
and js
aren't respected:
<link href="dist/bundle.min.css" rel="stylesheet">
How to solve this path related problem? And is it safe to to serve the page with sendFile
on a production server?