vitejs / vitejs/vite-plugin-react

change the react refresh url from `/@refresh-runtime`

Open
#1,015 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending triage plugin: react
Dominant language
TypeScript
Stars
1.2k
Forks
269
Avg merge
1d 3h
Merged PRs (30d)
19

Description

Related plugins
Description

in our application (tanstack start), there is an ssr route on /@{username} to show a user's profile, and the vite react plugin uses /@react-refresh without any trailing data. this causes the routes to conflict.

we never noticed this, because on localhost the browser sends Sec-Fetch-Dest: script, which vite uses to resolve the conflict. but in my current bug search, i am using the site from my phone in dev-mode, using the non-localhost http://169.254.x.x, which will not send these headers. the app now fails to run any client-side javascript since the script fetches "404 user not found" as HTML.

Suggested solution
  • change /@refresh-runtime to something else harder to collide with
    • perhaps /node_modules/@vitejs/plugin-react/dist/refresh-runtime.js to better reflect where the file is coming from
    • changeable with a configuration (my initial thought but i think the detailed path is better
Alternative

perhaps it should be configurable in vite to add a full prefix to the specifiers.

Additional context

i have a workaround (deleting the profile page temporarily) but would love this for coworkers that may need to perform a similar type of debug.

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the refresh-runtime handling in packages/plugin-react, packages/plugin-react-swc, and packages/plugin-react-oxc, then reproduce the conflict with an SSR route such as /@{username} without Sec-Fetch-Dest headers. Done means the React refresh request no longer collides with application routes across the checked plugins and client-side JavaScript still loads in dev mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript, vite
Domain
tooling, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.