f1nn
f1nn

Reputation: 7047

NodeJS+Express: serving static files for diffrerent URLs

I'm using node.js+express for serving static files (CSS+JS). At this time static dir is configured as

app.use(express.static(__dirname + '/static'));

In main templeate layout.jade I load static files as

link(href='css/bootstrap.css', rel='stylesheet')

Everything works fine with pages like /hello, /write, /:user. But when I get pages like /bob/505b6833d3835d3705000001/edit, static files cannot be found. Firebug shows Node generates the same path for static, but styles are not applied for the page. Why? Thanks in advance!

Upvotes: 0

Views: 1086

Answers (1)

Charlie Key
Charlie Key

Reputation: 3440

You should be using link with pre-slash.

link(href='/css/bootstrap.css', rel='stylesheet')

This should take care of it.

Upvotes: 2

Related Questions