Add cors open
This commit is contained in:
@@ -11,7 +11,7 @@ axum = { version = "0.7", optional = true }
|
||||
jsonwebtoken = { version = "9", optional = true }
|
||||
tokio = { version = "1.39", features = ["rt-multi-thread"], optional = true }
|
||||
tower = { version = "0.4", optional = true }
|
||||
tower-http = { version = "0.5", features = ["fs", "trace"], optional = true }
|
||||
tower-http = { version = "0.5", features = ["fs", "trace", "cors"], optional = true }
|
||||
sqlx = { version = "0.8", features = [
|
||||
"runtime-tokio-rustls",
|
||||
"sqlite",
|
||||
|
||||
@@ -21,10 +21,16 @@ pub async fn init_app(configuration_path: Option<&str>) {
|
||||
let leptos_options = conf.leptos_options;
|
||||
let serve_dir = tower_http::services::ServeDir::new(&leptos_options.site_root)
|
||||
.append_index_html_on_directories(false);
|
||||
|
||||
let cors = tower_http::cors::CorsLayer::new()
|
||||
.allow_methods([axum::http::Method::GET, axum::http::Method::POST])
|
||||
.allow_origin(tower_http::cors::Any);
|
||||
|
||||
logging::log!("listening on http://{}", &addr);
|
||||
let app = axum::Router::new()
|
||||
.leptos_routes(&leptos_options, routes, || view! { <App/> })
|
||||
.fallback_service(serve_dir)
|
||||
.layer(cors)
|
||||
.layer(
|
||||
tower_http::trace::TraceLayer::new_for_http()
|
||||
.make_span_with(
|
||||
|
||||
Reference in New Issue
Block a user