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

Fix fetchHttpClient issue with redirects #21051

Merged
merged 3 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/core/core-rest-pipeline/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### Bugs Fixed

- Updated `redirectPolicy` to remove the `Authorization` header from redirected requests. [#21026](https://github.com/Azure/azure-sdk-for-js/pull/21026)
- Fixed an issue introduced in 1.6.0 where redirects were not properly followed in the browser. [#21051](https://github.com/Azure/azure-sdk-for-js/pull/21051)

### Other Changes

Expand Down
1 change: 0 additions & 1 deletion sdk/core/core-rest-pipeline/src/fetchHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ async function makeRequest(request: PipelineRequest): Promise<PipelineResponse>
headers: headers,
signal: abortController.signal,
credentials: request.withCredentials ? "include" : "same-origin",
redirect: "manual",
Copy link
Member

@joheredi joheredi Mar 25, 2022

Choose a reason for hiding this comment

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

Allowing Fetch to automatically handle redirects means that our redirectPolicy will never kick in for browsers right?

Copy link
Member

Choose a reason for hiding this comment

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

If that's the behavior we want, I think it would be worth adding a comment in the redirect policy mentioning this, it would save future us a headache trying to debug redirects and realize later that Fetch is handling it for us

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, the policy won't kick in, but it won't kick in now since we get back status: 0 and no headers. I'll add a comment here too.

cache: "no-store",
});
return buildPipelineResponse(response, request);
Expand Down