Slightly simplify CORS example (#1027)

This commit is contained in:
Jonas Platte 2022-05-12 11:36:57 +02:00 committed by GitHub
parent 0b856b938f
commit 591434778f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,11 +26,11 @@ async fn main() {
// 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])"
// it is required to add ".allow_headers([http::header::CONTENT_TYPE])"
// or see this issue https://github.com/tokio-rs/axum/issues/849
CorsLayer::new()
.allow_origin("http://localhost:3000".parse::<HeaderValue>().unwrap())
.allow_methods(vec![Method::GET]),
.allow_methods([Method::GET]),
);
serve(app, 4000).await;
};