Skip to content

SPA fallback broken on LAN IP in dev with @cloudflare/vite-plugin enabled #9109

Closed
@kernpinoy

Description

@kernpinoy

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

  1. Create a Vite React project with the following plugins:
    • @vitejs/plugin-react-swc
    • @cloudflare/vite-plugin
    • @tanstack/router-plugin/vite
  2. Start the dev server with:
    bun run dev -- --host
    # or
    vite --host
  3. On another device on the same network, navigate to http://<your-ip>:5173/home (replace <your-ip> with your machine’s LAN IP).
  4. Observe that a 404 error is returned.
  5. Comment out or remove the @cloudflare/vite-plugin from vite.config.js.
  6. Restart the dev server and repeat step 3.
  7. 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 using localhost.

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

No one assigned

    Labels

    bugSomething that isn't workingvite-pluginRelating to the `@cloudflare/vite-plugin` package

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions