Skip to content

Commit

Permalink
#330: Set 'access-control-allow-origin' to the requests origin in cas…
Browse files Browse the repository at this point in the history
…e the "Access-Control-Allow-Credentials" is true
  • Loading branch information
msa0311 committed Mar 4, 2021
1 parent 9f1af82 commit fac9031
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/cors-anywhere.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ function withCORS(headers, request) {
delete request.headers['access-control-request-headers'];
}

//If "Access-Control-Allow-Credentials" is "true", "Access-Control-Allow-Origin" cannot be "*"!
//https://github.com/Rob--W/cors-anywhere/issues/330
if (headers['access-control-allow-credentials']) {
headers['access-control-allow-origin'] = request.headers['origin'];
}
headers['access-control-expose-headers'] = Object.keys(headers).join(',');

return headers;
Expand Down

0 comments on commit fac9031

Please sign in to comment.