Skip to content

Commit

Permalink
Removed the "redirect: manual" flag from fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
NSeydoux committed Oct 30, 2020
1 parent 40a6464 commit a22a607
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/browser/src/authenticatedFetch/fetchFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ async function buildDpopFetchOptions(
dpopKey
),
},
redirect: "manual",
};
}

function isAuthError(statusCode: number): boolean {
function isExpectedAuthError(statusCode: number): boolean {
return [401, 403].includes(statusCode);
}

Expand All @@ -90,9 +89,10 @@ export async function buildDpopFetch(
url,
await buildDpopFetchOptions(url.toString(), authToken, dpopKey, options)
);
const nonAuthNotOk = !response.ok && !isAuthError(response.status);
const failedButNotExpectedAuthError =
!response.ok && !isExpectedAuthError(response.status);
const hasBeenRedirected = response.url !== url;
if (response.ok || nonAuthNotOk || !hasBeenRedirected) {
if (response.ok || failedButNotExpectedAuthError || !hasBeenRedirected) {
// If there hasn't been a redirection, or if there has been a non-auth related
// issue, it should be handled at the application level
return response;
Expand Down

0 comments on commit a22a607

Please sign in to comment.