use_cookie signal tries to change cookie headers during SSR

Closes #124
This commit is contained in:
Marc-Stefan Cassola 2024-07-16 20:12:09 +01:00 committed by GitHub
parent 0975bdcfef
commit e192eff406
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -90,7 +90,9 @@ use std::rc::Rc;
/// This works equally well on the server or the client.
/// On the server this function reads the cookie from the HTTP request header and writes it back into
/// the HTTP response header according to options (if provided).
/// The returned `WriteSignal` will not affect the cookie headers on the server.
/// The returned `WriteSignal` may not affect the cookie headers on the server! It will try and write
/// the headers buy if this happens after the headers have already been streamed to the client then
/// this will have no effect.
///
/// > If you're using `axum` you have to enable the `"axum"` feature in your Cargo.toml.
/// > In case it's `actix-web` enable the feature `"actix"`, for `spin` enable `"spin"`.
@ -361,8 +363,9 @@ where
#[cfg(feature = "ssr")]
{
if !readonly {
create_isomorphic_effect(move |_| {
let value = cookie
.with_untracked(|cookie| {
.with(|cookie| {
cookie.as_ref().map(|cookie| {
C::encode(cookie)
.map_err(|err| on_error(CodecError::Encode(err)))
@ -385,6 +388,7 @@ where
ssr_set_cookie,
)
});
});
}
}