Skip to content

Commit 8fabd3a

Browse files
committed
FIX: Cors
1 parent 8d1f0ba commit 8fabd3a

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/controllers/docker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pub async fn is_alive() -> impl IntoResponse {
1313
let docker = get_docker_client();
1414

1515
match docker {
16-
Ok(_) => (StatusCode::OK, Json(json!({"message": "Docker is alive"}))).into_response(),
17-
Err(error) => error.into_response()
16+
Ok(_) => (StatusCode::OK, Json(json!({"status": 1}))).into_response(),
17+
Err(error) => (StatusCode::INTERNAL_SERVER_ERROR, Json(json!({"error": error.message, "status": 0}))).into_response()
1818
}
1919
}
2020

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ mod routes;
22
mod controllers;
33
mod errors;
44

5-
use axum::http::Method;
5+
use axum::http::{HeaderValue, Method};
66
use routes::setup_routes;
77
use tower_http::cors::{AllowOrigin, CorsLayer};
88

99
#[tokio::main]
1010
async fn main() {
1111
let cors = CorsLayer::new()
1212
.allow_methods(vec![Method::GET, Method::POST, Method::PUT, Method::DELETE])
13-
.allow_origin(AllowOrigin::exact("http://localhost:5173".parse().unwrap()));
13+
.allow_origin(AllowOrigin::list([
14+
HeaderValue::from_str("https://admin.bryan-ferrando.fr").unwrap(),
15+
HeaderValue::from_str("http://localhost:5173").unwrap()
16+
]));
1417

1518
let app = setup_routes().layer(cors);
1619

0 commit comments

Comments
 (0)