From ecf68b32f24deddbcefea4fff3185577b6a29089 Mon Sep 17 00:00:00 2001 From: Ruochen Lyu Date: Fri, 19 May 2023 18:01:31 +0800 Subject: [PATCH] fix CORS policy blocked --- cf-openai-azure-proxy.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cf-openai-azure-proxy.js b/cf-openai-azure-proxy.js index fea62b5..ff9e20d 100644 --- a/cf-openai-azure-proxy.js +++ b/cf-openai-azure-proxy.js @@ -60,7 +60,9 @@ async function handleRequest(request) { body: typeof body === 'object' ? JSON.stringify(body) : '{}', }; - const response = await fetch(fetchAPI, payload); + let response = await fetch(fetchAPI, payload); + response = new Response(response.body, response); + response.headers.set("Access-Control-Allow-Origin", "*"); if (body?.stream != true){ return response