I have mounted path like this
var path = require('path'); var express = require('express'); var app = express(); var admin = express(); admin.use(express.static(path.join(__dirname, 'public/'))); // mount admin path app.use('/admin', admin); Then I defined some route e.g
admin.get('/jobs', function(req, res){ res.render('jobs/index'); }); admin.get('/jobs/create', function(req, res){ res.render('jobs/create'); }); In the first route static files such as js,css,images loaded w/o problems. But in second one it does not load files.
Files loaded in views like this
<link rel="stylesheet" href="styles/css/main.css"> NOTE : styles directory is under public folder in my working directory.
So what is the problem ? What I did wrong ?
<link rel="stylesheet" href="/styles/css/main.css">. You need to add/at the starting for static assets.