aboutsummaryrefslogtreecommitdiff
path: root/src/api/admin/special.rs
diff options
context:
space:
mode:
authorAlex Auvolat <lx@deuxfleurs.fr>2025-01-28 18:15:36 +0100
committerAlex Auvolat <lx@deuxfleurs.fr>2025-01-29 19:26:16 +0100
commit4cb45bd398afd7966cec5d4dfa4dd325c114f93c (patch)
tree26373ab1007c21ff6fe810b64f74559710e115ad /src/api/admin/special.rs
parentd5ad797ad762dee4fc1244ad15fbee208ae58480 (diff)
downloadgarage-4cb45bd398afd7966cec5d4dfa4dd325c114f93c.tar.gz
garage-4cb45bd398afd7966cec5d4dfa4dd325c114f93c.zip
admin api: fix CORS to work in browser
Diffstat (limited to 'src/api/admin/special.rs')
-rw-r--r--src/api/admin/special.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/api/admin/special.rs b/src/api/admin/special.rs
index 0239021a..da3764d9 100644
--- a/src/api/admin/special.rs
+++ b/src/api/admin/special.rs
@@ -2,7 +2,9 @@ use std::sync::Arc;
use async_trait::async_trait;
-use http::header::{ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, ALLOW};
+use http::header::{
+ ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, ALLOW,
+};
use hyper::{Response, StatusCode};
use garage_model::garage::Garage;
@@ -20,9 +22,10 @@ impl EndpointHandler for OptionsRequest {
async fn handle(self, _garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> {
Ok(Response::builder()
- .status(StatusCode::NO_CONTENT)
- .header(ALLOW, "OPTIONS, GET, POST")
- .header(ACCESS_CONTROL_ALLOW_METHODS, "OPTIONS, GET, POST")
+ .status(StatusCode::OK)
+ .header(ALLOW, "OPTIONS,GET,POST")
+ .header(ACCESS_CONTROL_ALLOW_METHODS, "OPTIONS,GET,POST")
+ .header(ACCESS_CONTROL_ALLOW_HEADERS, "authorization,content-type")
.header(ACCESS_CONTROL_ALLOW_ORIGIN, "*")
.body(empty_body())?)
}