Set parameter SameSite to Lax for both cookies *dark_theme* and *lang*

This commit is contained in:
Greg Burri 2025-04-30 17:38:16 +02:00
parent 983002b5ec
commit 58e299b337
2 changed files with 5 additions and 3 deletions

View file

@ -4,7 +4,7 @@ use axum::{
http::{HeaderMap, StatusCode},
response::{IntoResponse, Result},
};
use axum_extra::extract::cookie::{Cookie, CookieJar};
use axum_extra::extract::cookie::{Cookie, CookieJar, SameSite};
// use tracing::{event, Level};
use crate::{
@ -29,7 +29,9 @@ pub async fn set_lang(
}
// Always set the cookie even is the user is connected in case of disconnection.
let cookie = Cookie::build((consts::COOKIE_LANG_NAME, ron.lang)).path("/");
let cookie = Cookie::build((consts::COOKIE_LANG_NAME, ron.lang))
.same_site(SameSite::Lax)
.path("/");
jar = jar.add(cookie);
Ok((jar, StatusCode::OK))

View file

@ -121,7 +121,7 @@ fn set_cookie_dark_theme(dark_theme: bool) {
domain: None,
expires: None,
secure: false,
same_site: wasm_cookies::SameSite::Strict,
same_site: wasm_cookies::SameSite::Lax,
},
);
}