Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow credential in cross origin request #646

Merged
merged 5 commits into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ssr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ use hot_or_not_web_leptos_ssr::{
app::App, init::AppStateBuilder, state::server::AppState,
utils::host::is_host_or_origin_from_preview_domain,
};
use http::{header, Method};
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, Any, CorsLayer};
use tower_http::cors::{AllowOrigin, CorsLayer};

pub async fn server_fn_handler(
State(app_state): State<AppState>,
Expand Down Expand Up @@ -145,8 +146,9 @@ async fn main() {
)
.layer(
CorsLayer::new()
.allow_headers(Any)
.allow_methods(Any)
.allow_credentials(true)
.allow_headers([header::AUTHORIZATION, header::CONTENT_TYPE, header::ACCEPT])
.allow_methods([Method::POST, Method::GET, Method::PUT, Method::OPTIONS])
.allow_origin(AllowOrigin::predicate(|origin, _| {
if let Ok(host) = origin.to_str() {
is_host_or_origin_from_preview_domain(host) || host == "yral.com"
Expand Down
Loading