Skip to content

fullstack: server fn with -> Result<SetHeader<SetCookie>> always returns Some(SetHeader { data: None }) #5089

@jarjk

Description

@jarjk

Problem

fullstack: server fn with -> Result<SetHeader<SetCookie>> always returns Some(Ok(SetHeader { data: None })) to client, browser kinda receives the proper HttpError's message as response json, but with 500 as code on Err no matter what.

Steps To Reproduce

check out the example

/// In our `login` form, we'll return a `SetCookie` header if the login is successful.
///
/// This will set a cookie in the user's browser that can be used for subsequent authenticated requests.
/// The `SetHeader::new()` method takes anything that can be converted into a `HeaderValue`.
///
/// We can set multiple headers by returning a tuple of `SetHeader` types, or passing in a tuple
/// of headers to `SetHeader::new()`.
#[post("/api/login")]
async fn login(form: Form<LoginForm>) -> Result<SetHeader<SetCookie>> {
// Verify the username and password. In a real application, you'd check these against a database.
if form.0.username == "admin" && form.0.password == "password" {
return Ok(SetHeader::new(format!("auth-demo={};", &*THIS_SESSION_ID))?);
}
HttpError::unauthorized("Invalid username or password")?
}

Steps to reproduce the behavior:

  • git clone https://github.com/dioxuslabs/dioxus
  • add a pre on line 38, just like
    pre { "Response from locked API: {fetch_sensitive.value():?}"}
    but with fetch_login
  • dx serve --example login_form
  • check login thingy

Expected behavior

make the dioxus client receive the proper Result<_, _> to be able to handle the Err properly, display the message to the user if necessary

Screenshots

Image Image

Environment:

  • Dioxus version: 0.7.2 (35351eb)
  • Rust version: 1.92.0 (ded5c06cf 2025-12-08)
  • OS info: aarch64 macos 26.1, tested on x86_64 (arch) linux as well, most probably not os specific
  • App platform: fullstack (web or desktop+server)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions