mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-31 09:18:29 +00:00
fix: return consistent cors headers on api error
This commit is contained in:
@@ -95,6 +95,7 @@ impl ApiError for Error {
|
|||||||
fn add_http_headers(&self, header_map: &mut HeaderMap<HeaderValue>) {
|
fn add_http_headers(&self, header_map: &mut HeaderMap<HeaderValue>) {
|
||||||
use hyper::header;
|
use hyper::header;
|
||||||
header_map.append(header::CONTENT_TYPE, "application/json".parse().unwrap());
|
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 {
|
fn http_body(&self, garage_region: &str, path: &str) -> ErrorBody {
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ impl ApiError for Error {
|
|||||||
fn add_http_headers(&self, header_map: &mut HeaderMap<HeaderValue>) {
|
fn add_http_headers(&self, header_map: &mut HeaderMap<HeaderValue>) {
|
||||||
use hyper::header;
|
use hyper::header;
|
||||||
header_map.append(header::CONTENT_TYPE, "application/json".parse().unwrap());
|
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 {
|
fn http_body(&self, garage_region: &str, path: &str) -> ErrorBody {
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ impl ApiError for Error {
|
|||||||
use hyper::header;
|
use hyper::header;
|
||||||
|
|
||||||
header_map.append(header::CONTENT_TYPE, "application/xml".parse().unwrap());
|
header_map.append(header::CONTENT_TYPE, "application/xml".parse().unwrap());
|
||||||
|
header_map.append(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*".parse().unwrap());
|
||||||
|
|
||||||
#[allow(clippy::single_match)]
|
#[allow(clippy::single_match)]
|
||||||
match self {
|
match self {
|
||||||
|
|||||||
Reference in New Issue
Block a user