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,6 +40,8 @@ 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);
res.once('header', function() {
// 6.2.7 // 6.2.7
res.header('Access-Control-Allow-Origin', req.headers['origin']); res.header('Access-Control-Allow-Origin', req.headers['origin']);
res.header('Access-Control-Allow-Credentials', true); res.header('Access-Control-Allow-Credentials', true);
@ -49,6 +51,9 @@ function preflightHandler(options) {
// 6.2.10 // 6.2.10
res.header('Access-Control-Allow-Headers', allowedHeaders.join(', ')); res.header('Access-Control-Allow-Headers', allowedHeaders.join(', '));
});
res.send(HTTP_NO_CONTENT); res.send(HTTP_NO_CONTENT);
}; };
} }