【问题标题】:RESTIFY not serving static files from subdirsRESTIFY 不从子目录提供静态文件
【发布时间】:2014-02-11 13:13:35
【问题描述】:

我正在尝试使用以下代码通过 restify 提供静态文件。

app.get(/.*/, restify.serveStatic({
    directory: __dirname + '/public',
    default: 'index.html'
}));

调用 GET / 或 GET /index.html 按预期工作。 调用 public 子目录中的任何文件都不起作用。 例如调用 GET /css/style.css 会导致 404。 文件存在但未被提供。

有什么想法吗?

【问题讨论】:

    标签: node.js restify


    【解决方案1】:

    试试这样,对我来说很好用:

    app.get(/.*/, restify.serveStatic({
        directory: 'public',
        default: 'index.html'
     }));
    

    【讨论】: