是否有可能,如果可以,如何指定自定义标题grunt-contrib-connect
?
问问题
1704 次
1 回答
5
您可以编写自己的中间件并指定req.headers
如下:
grunt.initConfig({
connect: {
server: {
options: {
middleware: function(connect, options) {
return [
function(req, res, next) {
// If path has .json, accept json
if (url.parse(req.url).pathname.match(/\.json$/)) {
req.headers.accept = 'application/json';
}
next();
},
// then serve a static folder
connect.static('base/folder/')
]
},
}
}
},
});
于 2013-12-11T03:48:20.087 回答