Skip to content

Commit

Permalink
fix: invalid Location header when using leptos_actix::redirect()
Browse files Browse the repository at this point in the history
…without JS/WASM (#2507)
  • Loading branch information
gbj authored Apr 9, 2024
1 parent 36b2f91 commit d74af81
Showing 1 changed file with 13 additions and 2 deletions.
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

0 comments on commit d74af81

Please sign in to comment.