Set headers during the "header" event

This commit is contained in:
rprieto 2014-05-08 21:50:09 +10:00
parent 07729dd7b3
commit 0e5633b2e8

View file

@ -40,15 +40,20 @@ function preflightHandler(options) {
allowedHeaders = DEFAULT_ALLOW_HEADERS.concat(['x-requested-with']) allowedHeaders = DEFAULT_ALLOW_HEADERS.concat(['x-requested-with'])
.concat(options.allowHeaders); .concat(options.allowHeaders);
// 6.2.7 res.once('header', function() {
res.header('Access-Control-Allow-Origin', req.headers['origin']);
res.header('Access-Control-Allow-Credentials', true);
// 6.2.9 // 6.2.7
res.header('Access-Control-Allow-Methods', allowedMethods.join(', ')); res.header('Access-Control-Allow-Origin', req.headers['origin']);
res.header('Access-Control-Allow-Credentials', true);
// 6.2.9
res.header('Access-Control-Allow-Methods', allowedMethods.join(', '));
// 6.2.10
res.header('Access-Control-Allow-Headers', allowedHeaders.join(', '));
});
// 6.2.10
res.header('Access-Control-Allow-Headers', allowedHeaders.join(', '));
res.send(HTTP_NO_CONTENT); res.send(HTTP_NO_CONTENT);
}; };
} }