Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ff111 fetch authorization cross origin #25127

Merged
merged 6 commits into from Mar 14, 2023

Conversation

hamishwillee
Copy link
Collaborator

@hamishwillee hamishwillee commented Mar 7, 2023

From FF111 if a fetch() or XMLHttpRequest request is redirected cross-origin, then a developer-added Authorization HTTP header will be removed from the request. The header is not stripped if the request is redirected to the same origin.

There isn't any particularly great place to record this information. What I have done is added it as a note to the option.headers value for fetch() and in the description for XMLHttpRequest.setRequestHeader() - I think that is the most likely place it will be seen. This also gets a note in the Authorization header.

I've also added a release note.

Other docs work can be tracked in #22533

@hamishwillee hamishwillee requested review from a team as code owners March 7, 2023 03:18
@hamishwillee hamishwillee requested review from Elchi3 and removed request for a team March 7, 2023 03:18
@github-actions github-actions bot added Content:Other Any docs not covered by another "Content:" label Content:WebAPI Web API docs labels Mar 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2023

Preview URLs

External URLs (2)

URL: /en-US/docs/Mozilla/Firefox/Releases/111
Title: Firefox 111 for developers


URL: /en-US/docs/Web/API/fetch
Title: fetch()

(comment last updated: 2023-03-10 03:26:27)

@@ -35,6 +35,9 @@ This article provides information about the changes in Firefox 111 that affect d

### HTTP

- The HTTP [`Authorization`](/en-US/docs/Web/HTTP/Headers/Authorization) header is removed from cross origin redirects.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this is part of the same work as the stuff down in APIs for fetch(). But it is kind of separate in that it is at the HTTP layer in code, and this is where you might look for it.

> allowed by Access-Control-Allow-Headers in preflight response**" exception
> when you send requests across domains. In this situation, you need to set up the
> {{HTTPHeader("Access-Control-Allow-Headers")}} in your response header at server side.
In addition, the [`Authorization`](/en-US/docs/Web/HTTP/Headers/Authorization) HTTP header may be added to a request, but will be removed if the request is redirected cross-origin.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this is the only new content here - the rest is layout. All it does is note that if the authorization header is added it will be stripped.

@hamishwillee hamishwillee requested a review from a team as a code owner March 10, 2023 03:24
@github-actions github-actions bot added the Content:HTTP HTTP docs label Mar 10, 2023
@rhclayto
Copy link

rhclayto commented Mar 11, 2023

Where is the best place to ask a question about this new feature? I am experiencing the Authorization header being stripped in Firefox Developer Edition, even though the response is not a cross-origin redirect. This is a request from a SPA using the Axios library to an API on the same subdomain & both using HTTPS. Setting network.fetch.redirect.stripAuthHeader = false makes it work again.

@Rumyra Rumyra merged commit 5d940b7 into mdn:main Mar 14, 2023
@Rumyra
Copy link
Collaborator

Rumyra commented Mar 14, 2023

Thanks @hamishwillee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:HTTP HTTP docs Content:Other Any docs not covered by another "Content:" label Content:WebAPI Web API docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants