mirror of
https://github.com/scratchfoundation/restify-cors-middleware.git
synced 2024-12-19 12:22:23 -05:00
Set headers during the "header" event
This commit is contained in:
parent
07729dd7b3
commit
0e5633b2e8
1 changed files with 12 additions and 7 deletions
|
@ -40,6 +40,8 @@ function preflightHandler(options) {
|
|||
allowedHeaders = DEFAULT_ALLOW_HEADERS.concat(['x-requested-with'])
|
||||
.concat(options.allowHeaders);
|
||||
|
||||
res.once('header', function() {
|
||||
|
||||
// 6.2.7
|
||||
res.header('Access-Control-Allow-Origin', req.headers['origin']);
|
||||
res.header('Access-Control-Allow-Credentials', true);
|
||||
|
@ -49,6 +51,9 @@ function preflightHandler(options) {
|
|||
|
||||
// 6.2.10
|
||||
res.header('Access-Control-Allow-Headers', allowedHeaders.join(', '));
|
||||
|
||||
});
|
||||
|
||||
res.send(HTTP_NO_CONTENT);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue