The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Return the redirect response when maxRedirects is 0
Rafi249890282d3e
diff --git a/apps/web/lib/api/safe-fetch.ts b/apps/web/lib/api/safe-fetch.tsindex 2b6cfe82c6..4ca3467b7d 100644--- a/apps/web/lib/api/safe-fetch.ts+++ b/apps/web/lib/api/safe-fetch.ts@@ -234,7 +234,10 @@ async function assertUrlIsSafe(url: URL): Promise<void> {type SafeFetchOptions = {/** Total timeout across all redirect hops. Defaults to 5000ms. */timeoutMs?: number;- /** Max number of redirects to follow. Defaults to 5. Set to 0 to disable. */+ /**+ * Max number of redirects to follow. Defaults to 5. Set to 0 to return a+ * redirect response as is, like `redirect: "manual"`.+ */maxRedirects?: number;};@@ -283,7 +286,7 @@ export async function safeFetch(const isRedirect = response.status >= 300 && response.status < 400;const location = response.headers.get("location");- if (!isRedirect || !location) {+ if (!isRedirect || !location || maxRedirects === 0) {return response;}