mirror of
https://github.com/tokio-rs/axum.git
synced 2025-03-13 19:27:53 +01:00
helpful note about posting with CORS (#938)
This commit is contained in:
parent
bef7700fcf
commit
0313c08dc9
1 changed files with 4 additions and 0 deletions
|
@ -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]),
|
||||
|
|
Loading…
Add table
Reference in a new issue