vitejs / vitejs/vite-plugin-react
change the react refresh url from `/@refresh-runtime`
Nobody has claimed this yet.
- 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-runtimeto something else harder to collide with- perhaps
/node_modules/@vitejs/plugin-react/dist/refresh-runtime.jsto better reflect where the file is coming from - changeable with a configuration (my initial thought but i think the detailed path is better
- perhaps
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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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