Skip to content

Commit 1bf3caa

Browse files
committed
fix(chat): set redirect follow to satisfy Cloudflare Workers fetch constraints
1 parent 96eb49c commit 1bf3caa

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎apps/site/src/pages/api/chat.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@ export const POST: APIRoute = async ({ request }) => {
114114
headers: {
115115
Authorization: `Bearer ${sanityToken}`,
116116
},
117-
fetch: (input, init) => globalThis.fetch(input, init),
117+
redirect: "follow",
118+
fetch: (input, init) => {
119+
const sanitizedInit = init ? { ...init } : {};
120+
if (sanitizedInit.redirect === "error") {
121+
sanitizedInit.redirect = "follow";
122+
}
123+
return globalThis.fetch(input, sanitizedInit);
124+
},
118125
},
119126
});
120127

0 commit comments

Comments
 (0)