expression4:redirect后,我无法得到我的静态文件

我遇到了Express 4和静态文件的麻烦。 成功login后,我的networking应用程序redirect到“/ home / userId”,但是,所有静态文件都得到了404。 这是我的路由器:

router.get('/home/:userid', function(req, res, next) { // TODO check if token is valid User.findById(req.params.userid).exec(function(err, find) { if (err) return next(err); if (!find) { return res.json(utils.createErrorJsonResponse(404, "User not found!")); } return res.render('home', { title: 'Organizator', user: find }); }) }); 

我觉得是不是有用的显示你我的玉文件,唯一重要的是,有很多导入的脚本,但只是举一个例子,这是我如何加载一个CSS文件:

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

这是我如何设置静态文件

  app.use(express.static(config.root + '/public',{ maxAge: 86400000 })); 

其中“config.root”是我的是:

 path.normalize(__dirname + '/..') 

正如我之前所说,如果我连接到基本页面,所以在我的情况:

 http://localhost:3000 

所有我的静态文件被导入,但只要我redirect,我得到了404。所以我怎么能解决它? 例如。 我有一个名为“style.css”的样式文件。 在控制台的基本页面(' http:// localhost:3000 ),我可以看到:

 Request URL:http://localhost:3000/css/style.css Request Method:GET Status Code:200 OK (from cache) 

然后从' http:// localhost:3000 / home / ':

 Request URL:http://localhost:3000/home/css/style.css Request Method:GET Status Code:404 Not Found 

所以问题是'/ home',但我怎样才能从静态文件请求中“移除”它? 谢谢。

正如@Molda在注释中所说的那样,确保你的链接以/开头,否则path将与实际路由http://localhost:3000/home