mirror of
https://github.com/tokio-rs/axum.git
synced 2025-10-02 15:24:54 +00:00
Slightly simplify CORS example (#1027)
This commit is contained in:
parent
0b856b938f
commit
591434778f
@ -26,11 +26,11 @@ async fn main() {
|
|||||||
// for more details
|
// for more details
|
||||||
//
|
//
|
||||||
// pay attention that for some request types like posting content-type: application/json
|
// 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
|
// or see this issue https://github.com/tokio-rs/axum/issues/849
|
||||||
CorsLayer::new()
|
CorsLayer::new()
|
||||||
.allow_origin("http://localhost:3000".parse::<HeaderValue>().unwrap())
|
.allow_origin("http://localhost:3000".parse::<HeaderValue>().unwrap())
|
||||||
.allow_methods(vec![Method::GET]),
|
.allow_methods([Method::GET]),
|
||||||
);
|
);
|
||||||
serve(app, 4000).await;
|
serve(app, 4000).await;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user