Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
与 Node.js 和 Express 混在一起。我现在只有以下内容:
app.get('*', function(req, res) { });
这应该捕获所有网址。排除静态文件的最佳方式是什么——以 .css、.js 和 .png 结尾(或者可能以“css/”、“js/”和“img/”开头)?
不要把你的静态文件放在./views. 将它们放入并在./public上面添加这一行app.use(app.router):
./views
./public
app.use(app.router)
app.use(express.static(path.join(__dirname, 'public')));
这就是你所需要的,你不需要其他任何东西。