3
是否可以,如果有的話如何指定自定義標題爲grunt-contrib-connect
?用grunt-contrib-connect指定標題
是否可以,如果有的話如何指定自定義標題爲grunt-contrib-connect
?用grunt-contrib-connect指定標題
你可以寫你自己的中間件,並指定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/')
]
},
}
}
},
});
這正是它。謝謝,凱爾。 –