From 9cff9ee450013e3f8d06b6fe4486c5e22aa9a845 Mon Sep 17 00:00:00 2001 From: Vishal <321vishalds@gmail.com> Date: Wed, 31 Jul 2024 22:27:17 +0530 Subject: [PATCH] Added CORS headers to `proxy_anthropic` (#8) --- src/handlers/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 078ad1b..5cf4bfe 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -41,7 +41,11 @@ pub async fn proxy_anthropic( Ok(response) => { let status = response.status(); let body = response.bytes().await.unwrap_or_default(); - HttpResponse::build(status).body(body) + HttpResponse::build(status) + .header("Access-Control-Allow-Origin", "https://zitefy.com") + .header("Access-Control-Allow-Methods", "POST, OPTIONS") + .header("Access-Control-Allow-Headers", "Content-Type, Authorization") + .body(body) }, Err(e) => HttpResponse::InternalServerError().body(format!("Error: {}", e)), }