Description
Which Cloudflare product(s) does this pertain to?
Vite Plugin
What versions & operating system are you using?
- OS: Arch Linux,
- Node.js: 23.11.0
- Bun: 1.2.10,
- Vite: 6.3.4,
- @cloudflare/vite-plugin: 1.0.13
- @tanstack/router-plugin: 1.117.2
Please provide a link to a minimal reproduction
https://github.com/kernpinoy/issue
Describe the Bug
When developing a React SPA with Vite and the @cloudflare/vite-plugin
, direct navigation to non-root routes (e.g., /home
) via the local network IP (e.g., http://10.0.0.25:5173/home
) results in a 404 error. This only occurs when the Cloudflare Vite plugin is enabled. The issue does not occur when accessing the same route via localhost
, nor does it occur when the Cloudflare plugin is disabled.
Steps to Reproduce
- Create a Vite React project with the following plugins:
@vitejs/plugin-react-swc
@cloudflare/vite-plugin
@tanstack/router-plugin/vite
- Start the dev server with:
bun run dev -- --host # or vite --host
- On another device on the same network, navigate to
http://<your-ip>:5173/home
(replace<your-ip>
with your machine’s LAN IP). - Observe that a 404 error is returned.
- Comment out or remove the
@cloudflare/vite-plugin
fromvite.config.js
. - Restart the dev server and repeat step 3.
- The route now loads as expected.
Expected Behavior
- Navigating directly to any client-side route (e.g.,
/home
) via the LAN IP should load the SPA and render the correct page, just as it does when usinglocalhost
.
Actual Behavior
- Navigating directly to a client-side route via the LAN IP returns a 404 error when the Cloudflare Vite plugin is enabled.
Additional Notes
- The issue does not occur when using
localhost
. - The issue does not occur when the Cloudflare plugin is disabled.
- Clicking links within the app (client-side navigation) works as expected.
- This behavior breaks mobile and cross-device testing in development.
Screen recordings
Please provide any relevant error logs
I was unable to get error logs as there was none. Sorry.
Metadata
Metadata
Assignees
Type
Projects
Status
Done