mirror of
https://github.com/scratchfoundation/restify-cors-middleware.git
synced 2024-12-18 11:52:26 -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
19
src/index.js
19
src/index.js
|
@ -40,15 +40,20 @@ function preflightHandler(options) {
|
|||
allowedHeaders = DEFAULT_ALLOW_HEADERS.concat(['x-requested-with'])
|
||||
.concat(options.allowHeaders);
|
||||
|
||||
// 6.2.7
|
||||
res.header('Access-Control-Allow-Origin', req.headers['origin']);
|
||||
res.header('Access-Control-Allow-Credentials', true);
|
||||
res.once('header', function() {
|
||||
|
||||
// 6.2.9
|
||||
res.header('Access-Control-Allow-Methods', allowedMethods.join(', '));
|
||||
// 6.2.7
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue