diff --git a/packages/backend/src/misc/fetch.ts b/packages/backend/src/misc/fetch.ts index d94c1f9a1..aaa876373 100644 --- a/packages/backend/src/misc/fetch.ts +++ b/packages/backend/src/misc/fetch.ts @@ -83,6 +83,9 @@ export async function getResponse(args: { }); if (args.redirect === "manual" && [301, 302, 307, 308].includes(res.status)) { + if (!isValidUrl(res.url)) { + throw new StatusError("Invalid URL", 400); + } return res; } @@ -94,10 +97,6 @@ export async function getResponse(args: { ); } - if (res.redirected && !isValidUrl(res.url)) { - throw new StatusError("Invalid URL", 400); - } - return res; }