重新整理,提供文件夹中的静态文件以及所有HTML作为index.html

时间:2018-11-28 20:43:04

标签: javascript node.js routes restify static-files

我开始学习NodeJS,并与Restify一起玩。

我将使用AngularJS,它是视图路由器,所以我希望所有视图最终指向保存的实际index.html

我尝试将我的网络服务器配置为提供静态文件(.css,.jpg等), 但对于所有/ html /请求,应返回index.html,如下所示:

server.get('/web/*.html', restify.plugins.serveStatic({
  directory: __dirname + '\\web',
  file: 'index.html'
}));

server.get('/web/*', restify.plugins.serveStatic({
  directory: __dirname + '\\web',
  default: 'index.html'
}));

但它可以将/web/下的所有内容用作index.html
(例如localhost:8080 / web / myimage.jpg还会使我的index.html更加繁忙)

似乎像第一个'/web/*.html'一样会忽略我的,html比赛而触发。

我在哪里错了?

0 个答案:

没有答案
相关问题