From a0c2cf328e083713033b967ad43ad3912e32f2ac Mon Sep 17 00:00:00 2001 From: Johann150 Date: Thu, 5 Jan 2023 20:03:38 +0100 Subject: [PATCH] server: fix redirected fetch Don't throw a StatusError on an intended redirect. --- packages/backend/src/misc/fetch.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/misc/fetch.ts b/packages/backend/src/misc/fetch.ts index 661716e25..42eb445d9 100644 --- a/packages/backend/src/misc/fetch.ts +++ b/packages/backend/src/misc/fetch.ts @@ -54,7 +54,11 @@ export async function getResponse(args: { url: string, method: string, body?: st signal: controller.signal, }); - if (!res.ok) { + if ( + !res.ok + && + // intended redirect is not an error + !(args.redirect != 'follow' && res.status >= 300 && res.status < 400)) { throw new StatusError(`${res.status} ${res.statusText}`, res.status, res.statusText); }