Skip to content

Trailing slash stripped from request.url in loader during client navigation #12465

Open
@richardkall

Description

@richardkall

I'm using React Router as a...

framework

Reproduction

  1. Go to https://stackblitz.com/edit/stackblitz-starters-xvygdk
  2. Click the "About" link inside the preview, which points to /about/
  3. Notice the missing trailing slash on the rendered request.url.
  4. Reload the About page, notice the trailing slash now being appended to the request.url.

System Info

react-router@7.0.2 (app created using `npx create-react-router@latest`)

Used Package Manager

npm

Expected Behavior

  • request.url in loader to contain a trailing slash, since that's the URL I'm at.
  • request.url behaving consistently no matter if I'm client side navigating or SSR.

Why is this important?
We are fetching data inside the loader, and need to pass the pathname to an API. The API responds differently depending on if certain pages have trailing slash or not (tells the client to redirect etc.). This issue leads to redirect loops and blocks us from migrating to React Router 7.

Actual Behavior

  • request.url is missing a trailing slash, although that is the URL I'm at.
  • request.url contains a trailing slash during SSR, but strips it during client side navigation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions