Skip to content

[Bug]: Implements RFC 7807/9457 "Problem Details for HTTP APIs" #11032

@Maxouwell

Description

@Maxouwell

What version of React Router are you using?

6.17.0

Steps to Reproduce

RFC 7807/9457 introduced a extensible format for json error response, and a dedicated Content-Type : "application/problem+json".
Some server framework start to respond with this Content-Type on error (Spring Framework 6 for example).

When these responses are returned on a loader or action, the resulting response is used as text instead of a json:
(packages/router/router.ts#L3925)

    let contentType = result.headers.get("Content-Type");
    // Check between word boundaries instead of startsWith() due to the last
    // paragraph of https://httpwg.org/specs/rfc9110.html#field.content-type
    if (contentType && /\bapplication\/json\b/.test(contentType)) {
      data = await result.json();
    } else {
      data = await result.text();
    }

Would it be possible to add the new Content Type ?

Expected Behavior

useLoaderData or useActionData returns a Javascript object

Actual Behavior

useLoaderData or useActionData returns a string

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions