I using express to build web app. I have problems with routes or static files. I added reference to static files:
app.use(express.static(path.join(__dirname, 'public')));
and set routes:
app.use('/', routes);
app.use('/users', users);
app.use('/blog', blog);
In my blog router:
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res) {
res.render('blog/index');
});
/* GET registration form. */
router.get('/registration', function(req, res) {
res.render('blog/registration');
});
module.exports = router;
So my problem:
When I go to /blog my static files loading correctly (without blog in path). But when I go to /blog/registration I get error (with blog in path):
GET /blog/stylesheets/css/bootstrap.min.css registration:1
GET /blog/stylesheets/lib/og-component.css registration:1
GET /blog/stylesheets/lib/venobox.css registration:1
GET /blog/stylesheets/lib/zocial.css registration:1
GET /blog/stylesheets/lib/font-awesome.css registration:1
GET /blog/stylesheets/lib/animate.css registration:1
GET /blog/stylesheets/css/style.css registration:1
GET /blog/stylesheets/css/scheme/light-blue.css registration:1
GET /blog/js/lib/modernizr.custom.js registration:1
GET /blog/images/jssolutions-logo.png 404 (Not Found)
How I can fix this problem: load static files without blog in path:
/stylesheets/css/bootstrap.min.css
/or~/?~/will only work if some server-side processing resolves it - HTML doesn't understand the tilde.