From 5322c5c29b1509ac15307a17654580f25f1ac3eb Mon Sep 17 00:00:00 2001 From: ravi-sawlani-yral Date: Fri, 31 Jan 2025 15:11:34 +0530 Subject: [PATCH 1/3] allow headers in the request --- ssr/src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ssr/src/main.rs b/ssr/src/main.rs index 5933ee43..be30e5ad 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,6 +144,7 @@ async fn main() { get(server_fn_handler).post(server_fn_handler), ) .layer( +<<<<<<< Updated upstream 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" @@ -151,6 +152,17 @@ async fn main() { false } })), +======= + CorsLayer::new() + .allow_headers(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 + } + })), +>>>>>>> Stashed changes ) .leptos_routes_with_handler(routes, get(leptos_routes_handler)) .fallback(file_and_error_handler) From 0bb0ef97cfe5bad4fa725a190570f1c723d90dd9 Mon Sep 17 00:00:00 2001 From: ravi-sawlani-yral Date: Fri, 31 Jan 2025 15:21:09 +0530 Subject: [PATCH 2/3] resovle conflicts --- ssr/src/main.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ssr/src/main.rs b/ssr/src/main.rs index be30e5ad..c18cbef8 100644 --- a/ssr/src/main.rs +++ b/ssr/src/main.rs @@ -144,15 +144,6 @@ async fn main() { get(server_fn_handler).post(server_fn_handler), ) .layer( -<<<<<<< Updated upstream - 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_origin(AllowOrigin::predicate(|origin, _| { @@ -162,7 +153,6 @@ async fn main() { false } })), ->>>>>>> Stashed changes ) .leptos_routes_with_handler(routes, get(leptos_routes_handler)) .fallback(file_and_error_handler) From afec2e280c31e231a020f5314a093c0272102dbe Mon Sep 17 00:00:00 2001 From: ravi-sawlani-yral Date: Fri, 31 Jan 2025 15:23:15 +0530 Subject: [PATCH 3/3] allow methods --- ssr/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ssr/src/main.rs b/ssr/src/main.rs index c18cbef8..e614738d 100644 --- a/ssr/src/main.rs +++ b/ssr/src/main.rs @@ -146,6 +146,7 @@ async fn main() { .layer( 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"