From a22a607d3f2a5d0ec5809192894b8c89e9b3b754 Mon Sep 17 00:00:00 2001 From: Nicolas Seydoux Date: Fri, 30 Oct 2020 15:41:34 +0100 Subject: [PATCH] Removed the "redirect: manual" flag from fetch --- packages/browser/src/authenticatedFetch/fetchFactory.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/browser/src/authenticatedFetch/fetchFactory.ts b/packages/browser/src/authenticatedFetch/fetchFactory.ts index f167e5751a..8db4f006c7 100644 --- a/packages/browser/src/authenticatedFetch/fetchFactory.ts +++ b/packages/browser/src/authenticatedFetch/fetchFactory.ts @@ -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); } @@ -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;