fix: return consistent cors headers on api error

This commit is contained in:
Xavier Stouder
2025-07-30 22:19:48 +02:00
parent e226fb413f
commit 0dabf9b22f
3 changed files with 3 additions and 0 deletions

View File

@@ -95,6 +95,7 @@ impl ApiError for Error {
fn add_http_headers(&self, header_map: &mut HeaderMap<HeaderValue>) {
use hyper::header;
header_map.append(header::CONTENT_TYPE, "application/json".parse().unwrap());
header_map.append(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*".parse().unwrap());
}
fn http_body(&self, garage_region: &str, path: &str) -> ErrorBody {

View File

@@ -99,6 +99,7 @@ impl ApiError for Error {
fn add_http_headers(&self, header_map: &mut HeaderMap<HeaderValue>) {
use hyper::header;
header_map.append(header::CONTENT_TYPE, "application/json".parse().unwrap());
header_map.append(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*".parse().unwrap());
}
fn http_body(&self, garage_region: &str, path: &str) -> ErrorBody {

View File

@@ -176,6 +176,7 @@ impl ApiError for Error {
use hyper::header;
header_map.append(header::CONTENT_TYPE, "application/xml".parse().unwrap());
header_map.append(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*".parse().unwrap());
#[allow(clippy::single_match)]
match self {