Skip to content

Commit

Permalink
ensure that passed in headers can override CORS headers
Browse files Browse the repository at this point in the history
  • Loading branch information
cjus committed Oct 12, 2020
1 parent 1a4657a commit 12a49be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/server-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ class ServerResponse {
'Content-Type': 'application/json'
};

if (data) {
headers = Object.assign(headers, data.headers);
}

let response = Object.assign(this.createResponseObject(code), data || {});
if (this.corsEnabled) {
headers = Object.assign(headers, this.corsHeaders);
}

if (data) {
headers = Object.assign(headers, data.headers);
}

let responseString = JSON.stringify(response);
headers['Content-Length'] = Buffer.byteLength(responseString);

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hydra",
"version": "1.8.0",
"version": "1.8.1",
"license": "MIT",
"author": "Carlos Justiniano",
"contributors": "https://github.com/pnxtech/hydra/graphs/contributors",
Expand Down Expand Up @@ -36,8 +36,8 @@
"eslint": "4.18.2",
"eslint-config-google": "0.7.1",
"eslint-plugin-mocha": "4.9.0",
"mocha": "^8.1.3",
"nyc": "^15.1.0",
"mocha": "8.1.3",
"nyc": "15.1.0",
"redis-mock": "0.17.0"
},
"nyc": {
Expand Down

0 comments on commit 12a49be

Please sign in to comment.