server: fix redirected fetch

Don't throw a StatusError on an intended redirect.
This commit is contained in:
Johann150 2023-01-05 20:03:38 +01:00
parent 334368f6e2
commit a0c2cf328e
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -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);
}