From 86ab4c8544272b1c6a2742283fb9c3fdda376547 Mon Sep 17 00:00:00 2001 From: Ravi Sawlani <152961362+ravi-sawlani-yral@users.noreply.github.com> Date: Fri, 31 Jan 2025 15:39:47 +0530 Subject: [PATCH] feat: allow headers and all methods in the request (#644) * allow headers in the request * resovle conflicts * allow methods --- ssr/src/main.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ssr/src/main.rs b/ssr/src/main.rs index 5933ee43..e614738d 100644 --- a/ssr/src/main.rs +++ b/ssr/src/main.rs @@ -13,7 +13,7 @@ use hot_or_not_web_leptos_ssr::{ use leptos::{get_configuration, logging::log, provide_context}; use leptos_axum::handle_server_fns_with_context; use leptos_axum::{generate_route_list, LeptosRoutes}; -use tower_http::cors::{AllowOrigin, CorsLayer}; +use tower_http::cors::{AllowOrigin, Any, CorsLayer}; pub async fn server_fn_handler( State(app_state): State, @@ -144,13 +144,16 @@ async fn main() { get(server_fn_handler).post(server_fn_handler), ) .layer( - CorsLayer::new().allow_origin(AllowOrigin::predicate(|origin, _| { - if let Ok(host) = origin.to_str() { - is_host_or_origin_from_preview_domain(host) || host == "yral.com" - } else { - false - } - })), + CorsLayer::new() + .allow_headers(Any) + .allow_methods(Any) + .allow_origin(AllowOrigin::predicate(|origin, _| { + if let Ok(host) = origin.to_str() { + is_host_or_origin_from_preview_domain(host) || host == "yral.com" + } else { + false + } + })), ) .leptos_routes_with_handler(routes, get(leptos_routes_handler)) .fallback(file_and_error_handler)