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: invalid Location header when using leptos_actix::redirect() without JS/WASM (closes #2506) #2507

Merged
merged 1 commit into from
Apr 9, 2024
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
15 changes: 13 additions & 2 deletions integrations/actix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,19 @@ pub fn handle_server_fns_with_context(

// Use provided ResponseParts headers if they exist
let headers = res.headers_mut();
for (k, v) in std::mem::take(&mut res_parts.0.write().headers) {
headers.append(k.clone(), v.clone());
let mut res_parts = res_parts.0.write();

// Location is set to redirect to Referer in the server handler handler by default,
// but it can only have a single value
//
// if we have used redirect() we will end up appending this second Location value
// to the first one, which will cause an invalid response
// see https://github.com/leptos-rs/leptos/issues/2506
for location in res_parts.headers.remove(header::LOCATION) {
headers.insert(header::LOCATION, location);
}
for (k, v) in std::mem::take(&mut res_parts.headers) {
headers.append(k, v);
}

// clean up the scope
Expand Down
Loading