From 949eb42d0a616b7ddf8fc1fd82e515598922a7e0 Mon Sep 17 00:00:00 2001 From: arrake Date: Sat, 2 Nov 2024 23:41:20 +0800 Subject: [PATCH] Support CORS policy for requests --- src/server/ctx/util.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server/ctx/util.rs b/src/server/ctx/util.rs index 7ada1b6..7d77383 100644 --- a/src/server/ctx/util.rs +++ b/src/server/ctx/util.rs @@ -39,6 +39,9 @@ pub fn html_headers() -> HeaderMap { pub fn json_headers() -> HeaderMap { let mut headers = HeaderMap::new(); headers.insert(header::CONTENT_TYPE, "application/json".parse().unwrap()); + headers.insert(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*".parse().unwrap()); + headers.insert(header::ACCESS_CONTROL_ALLOW_METHODS, "GET, POST, OPTIONS".parse().unwrap()); + headers.insert(header::ACCESS_CONTROL_ALLOW_HEADERS, "Content-Type".parse().unwrap()); headers }