Skip to content

Commit

Permalink
Add User-Agent header to CORS preflight requests
Browse files Browse the repository at this point in the history
Fixes #1659.

This mirrors the behavior of other browsers, and fixes broken XHR
requests to APIs that require a User-Agent header for all requests,
such as api.github.com.
  • Loading branch information
BehindTheMath authored and domenic committed Apr 30, 2018
1 parent 9b25ba5 commit 1e252e0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/jsdom/living/xhr-utils.js
Expand Up @@ -349,6 +349,8 @@ function createClient(xhr) {
preflightRequestHeaders["Access-Control-Request-Headers"] = nonSimpleHeaders.join(", ");
}

preflightRequestHeaders["User-Agent"] = requestHeaders["User-Agent"];

flag.preflight = true;

const preflightOptions = {
Expand Down

0 comments on commit 1e252e0

Please sign in to comment.