2014-01-21 62 views
2

我试图用restify使用以下代码服务静态文件。RESTIFY不从服务器提供静态文件

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

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

任何想法?

回答

1

试试这个样子,对我来说工作得很好:

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