mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-25 00:00:23 +02:00
Update to tower-http 0.3.0 (#965)
* Update to tower-http 0.3.0 * changelog link
This commit is contained in:
@@ -5,13 +5,13 @@
|
||||
//! ```
|
||||
|
||||
use axum::{
|
||||
http::Method,
|
||||
http::{HeaderValue, Method},
|
||||
response::{Html, IntoResponse},
|
||||
routing::get,
|
||||
Json, Router,
|
||||
};
|
||||
use std::net::SocketAddr;
|
||||
use tower_http::cors::{CorsLayer, Origin};
|
||||
use tower_http::cors::CorsLayer;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
@@ -29,7 +29,7 @@ async fn main() {
|
||||
// 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_origin("http://localhost:3000".parse::<HeaderValue>().unwrap())
|
||||
.allow_methods(vec![Method::GET]),
|
||||
);
|
||||
serve(app, 4000).await;
|
||||
|
||||
Reference in New Issue
Block a user