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

fix: prevent multiple location headers on redirect (#3298) #3311

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

veigaribo
Copy link
Contributor

The problem turned out to be specific to 0.7 Actix, which I did not expect.

This solution is what was proposed by @gbj in #3298, although I did not make the new code part of extend_response because extend_response is also called in handle_static_route, and I don't think it needs this (maybe I'm wrong?).

I believe a better solution would actually be to match the Axum behavior, that uses http::HeaderMap::extend: For merging map A with map B, if map B contains a key that is present in A, all values with such key in A are removed and all values with that key in B are added. That would at least be more consistent.

I also still don't understand why both server_fn::ServerFn::run_on_server and leptos_actix::handle_server_fns_with_context need to handle redirection to Referer, but I assume there is a reason.

Took the oportunity to fix the surrounding comments too, to the best of my ability.

@benwis
Copy link
Contributor

benwis commented Dec 2, 2024

I think the problem with this one is that headers like Set-Cookie are set multiple times and should not be overwritten this way

@veigaribo
Copy link
Contributor Author

I think the problem with this one is that headers like Set-Cookie are set multiple times and should not be overwritten this way

I think this solution is pretty hacky, but it should not affect any header other than Location 🤔 because that's what we call .remove() on

@benwis
Copy link
Contributor

benwis commented Dec 2, 2024

LGTM, seems ideal

@benwis benwis merged commit fcba8b3 into leptos-rs:main Dec 2, 2024
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants