我刚开始在流星上使用铁路由器。我需要在主页上显示图像。我能够使用客户端路由为“家”配置路由。对于静态文件,我尝试 google 并发现添加服务器端路由可能会有所帮助。因此,我在服务器的 router.js 上添加了以下代码。
Router.map(function() {
this.route('files', {
path: '/files/:path(*)',
action: function() {
var path = this.params.path;
console.log('will serve static content @ '+path);
this.response.sendfile(path);
}
});
});
当我尝试访问http://localhost:3000/files/someImage.png
时,它说没有为/files/someImage.png
. 难道我做错了什么?有没有其他方法可以使用 Iron 路由器提供静态文件?