From d4c36be288d99b16bdbefb199ad9ecc7fc7888b1 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Thu, 23 Feb 2023 15:10:38 -0500 Subject: [PATCH] [O] CORS allow --- backend/src/macros.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/macros.rs b/backend/src/macros.rs index eb329d9..9311965 100644 --- a/backend/src/macros.rs +++ b/backend/src/macros.rs @@ -1,5 +1,5 @@ use std::path::PathBuf; -use hyper::{Body, http, Response, StatusCode}; +use hyper::{Body, header, http, Response, StatusCode}; pub trait StringExt { fn resp(&self, status: u16) -> http::Result>; @@ -7,7 +7,8 @@ pub trait StringExt { impl StringExt for String { fn resp(&self, status: u16) -> http::Result> { - Response::builder().status(StatusCode::from_u16(status).unwrap()).body(Body::from(self.to_owned())) + Response::builder().header(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*") + .status(StatusCode::from_u16(status).unwrap()).body(Body::from(self.to_owned())) } }