question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Error: Headers Authorization forbidden" in CORS

See original GitHub issue

Hey,

I have a test running with jsdom, in which i’m sending a cross-origin request with an Authorization header (i’m using nock to mock the server). As expected, an OPTIONS preflight request is sent. However i’m receiving an exception, saying that the Authorization header is forbidden in the preflight request. Since i’m not controlling which headers are being sent in the preflight request, I have a feeling that this might be a bug.

So I searched the code a bit, and tried to debug this, and I encountered this line of code: https://github.com/jsdom/jsdom/blob/4bc7f53fed9a5387275f52ae07a85e7d4b790391/lib/jsdom/living/xhr-utils.js#L91

It seems that in the validCORSPreflightHeaders function, the original request headers are being validated instead of the preflight headers.

Is this correct? Or am I missing something?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
jonathanadlercommented, Nov 1, 2018

After trying to duplicate the error without axios and nock, i’ve resolved the issue. I have forgotten to add the header: 'access-control-allow-headers': 'Authorization' in my response from the server.

Sorry for taking your time, and thanks for your help.

2reactions
domeniccommented, Oct 31, 2018

Can you provide a minimal example to reproduce this issue, per the issue template? Including important information like the versions in use, etc. We can’t really debug based on this description.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CORS error: Request header field Authorization is not allowed ...
The error usually occurs when the Authorization header or the OPTIONS method is missing from the server's response headers.
Read more >
Reason: Credential is not supported if the CORS header ...
The CORS request was attempted with the credentials flag set, but the server is configured using the wildcard ( "*" ) as the...
Read more >
CORS error :Request header field Authorization is not allowed ...
This is an API issue, you won't get this error if using Postman/Fielder to send HTTP requests to API. In case of browsers,...
Read more >
Which CORS headers do you need to send an Authorization ...
When an unauthenticated request is received by the server, it will respond with a HTTP 401 Unauthorized response with a WWW-Authenticate header.
Read more >
Troubleshoot CORS errors from API Gateway - AWS
Cross-Origin Resource Sharing (CORS) errors occur when a server doesn't return the HTTP headers required by the CORS standard.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found