middleware is not properly setting the header
amir-rahnama opened this issue · 1 comments
amir-rahnama commented
grunt@0.4.5
grunt-contrib-connect@0.10.1
grunt-contrib-watch@0.6.1
Here is my config file but for some strange reasons,
connect: {
server: {
options: {
port: 9001,
base: '.',
open: true,
livereload: true,
middleware: function(connect, options, middlewares) {
middlewares.unshift(function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
});
return middlewares;
},
},
}
}`
although the code gets executed, the requests still don't have the headers.
yingnansong commented
Change your middleware function from
function(req, res, next) { res.setHeader('Access-Control-Allow-Origin', '*'); next(); }
to
function(req, res, next) { res.setHeader('Access-Control-Allow-Origin', '*'); return next(); }