【问题标题】:express.static middleware not looking in the specified directory (for serving static files)express.static 中间件不在指定目录中查找(用于提供静态文件)
【发布时间】:2014-04-24 05:10:29
【问题描述】:

我有一个相当简单的设置

app.configure(function() {
    app.use('/public', express.static(__dirname + '/public'));
    app.use(app.router);
});

app.get('/', function(req, res) {
...

我请求/somefile 并希望快递在/public/somefile 中寻找它。

但它看起来并不在那里。

但是当我直接查找public/somefile 时,它确实找到了。

我的代码有问题吗?

【问题讨论】:

  • 您使用的是 Express 4 吗?
  • @mscdex 也许,我该如何检查?昨天我对节点 0.10.26 做了update
  • @Vinz243 谢谢。 └── express@3.4.8
  • 如果你尝试一下:server.use(express.static(path.join(__dirname.getParent(), "/public")));path = require("path");
  • @Vinz243 是 this getParent()? (没有它has no method 'getParent')有了它,它仍然不起作用..

标签: node.js express connect


【解决方案1】:

这只是一个缓存问题。强制重新加载修复它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多