Skip to content

useFetcher.submit causes 404 when basename is set in react-router.config.ts #14458

@fushihara

Description

@fushihara

Reproduction

stackblitz
https://stackblitz.com/edit/2025-10-17-41732624-836b-4844-4054-e103b9099801?file=src%2Fapp%2Froutes%2Farticle.tsx

When basename is specified in react-router.config.ts, calling useFetcher().submit() causes the client to navigate to a 404 page.
This issue does not occur when no basename is set.

2025-10-17-01-09-42.mp4

After tracing the execution in debug mode, I found that the problem seems to originate in the normalizeTo function.
It appears that the normalizedPath string is being constructed incorrectly.
For example, when I set:
basename = "/react-router-base/"

the resulting value of normalizedPath becomes:
/react-router-base/react-router-base/?index
—notice that basename is duplicated.
Image

If I manually change the value of normalizedPath in the debugger to:
/react-router-base/?index
the 404 behavior disappears and everything works correctly.

I filed another issue yesterday, but I realized that I described the wrong root cause.
This new issue correctly points out the actual problem.

System Info

from stackblitz

❯ npx envinfo --system --npmPackages '{vite,react-router,@react-router/*}' --binaries --browsers
   System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @react-router/dev: 7.9.4 => 7.9.4 
    @react-router/node: 7.9.4 => 7.9.4 
    @react-router/serve: 7.9.4 => 7.9.4 
    react-router: 7.9.4 => 7.9.4 
    vite: 7.1.10 => 7.1.10

Used Package Manager

npm

Expected Behavior

navigation to 404 page.
↓ here is a movie
https://github.com/user-attachments/assets/45a48a82-75ce-40da-a450-ecf167300647

Actual Behavior

When calling fetcher.submit(), the page should not switch to a 404 screen.

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