Is it possible and if so how can one specify custom headers with grunt-contrib-connect
?
Asked
Active
Viewed 1,728 times
3

Brian M. Hunt
- 81,008
- 74
- 230
- 343
1 Answers
5
You can write your own middleware and specify req.headers
like such:
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/')
]
},
}
}
},
});

hirse
- 2,394
- 1
- 22
- 24

Kyle Robinson Young
- 13,732
- 1
- 47
- 38
-
That's exactly it. Thanks, Kyle. – Brian M. Hunt Dec 11 '13 at 13:01