When my app is loaded from a url like: server.com/pdf/12345
, it tries to find static files at
GET /pdf/12345/assets/css/stylesheet.css
and returns a 404 error. I've been struggling to get it to search for the files in /public/assets
instead. I've tried various configurations with express.static
but haven't had any luck.
This is how my directory structure is set up:
public
--assets
----css
views
--partials
----header.ejs
routes
--api.js
server.js
The server.js file looks something like this (excluding requires for simplicity):
app.use('/', routes);
app.set('views', './views');
app.set('view engine', 'ejs');
app.use('/public', express.static(path.join(__dirname, 'public')));
http.createServer(app).listen(port, function() {
})
Within my partials/header.ejs file, there's a link to the stylesheet.