From 0313c08dc927d23363646e579cfcd6f2a75cae57 Mon Sep 17 00:00:00 2001 From: Slava Date: Sun, 17 Apr 2022 11:13:22 +0300 Subject: [PATCH] helpful note about posting with CORS (#938) --- examples/cors/src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/cors/src/main.rs b/examples/cors/src/main.rs index 14c4e1b4..28fa05f0 100644 --- a/examples/cors/src/main.rs +++ b/examples/cors/src/main.rs @@ -24,6 +24,10 @@ async fn main() { let app = Router::new().route("/json", get(json)).layer( // see https://docs.rs/tower-http/latest/tower_http/cors/index.html // for more details + // + // pay attention that for some request types like posting content-type: application/json + // it is required to add ".allow_headers(vec![http::header::CONTENT_TYPE])" + // or see this issue https://github.com/tokio-rs/axum/issues/849 CorsLayer::new() .allow_origin(Origin::exact("http://localhost:3000".parse().unwrap())) .allow_methods(vec![Method::GET]),