Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

tanstack + nitro + vite allowedHosts issue repro

so it seems that if you use a allowedHost which just resolved to 127.0.0.1 nitro somehow breaks vite and does not return the correct js modules for some packages.

If you open the page via localhost everything works as expected but if you use any domain that is inside vite's allowedHost array some JS modules are returned with the content of the splat route and the dev tools either throw an error:

Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

or simply a 500. Removing the nitro() plugin from the vite.config.tssolves this issue so I am pretty confident that it is produced by nitro.

Testing / Reproduction

pnpm install
pnpm dev --host

open your browser, dev tools and then go to https://local.dunklestoast.de:3000 (this is just a DNS Entry that resolves locally to your machine. I thought it might be easier to test if I provide one but you can also use any other domain or add one via your /etc/resolv file and update vite.config.ts).

Small note: Some routers (like fritzbox) have a DNS Rebind Protection so if you have that issue, use the /etc/resolv

In your dev tools you should now see an error on the env.mjs file and if you inspect the response content you will see that this is just the response of the splat ($.tsx) route instead of the vite response which should've been sent. Calling localhost does not yield this issue.

I've tested this with all 3.x.x releases and it seems like it was fixed briefly:

Version Status
3.0.0 fail
3.0.1-alpha.0 fail
3.0.1-alpha.1 fail
3.0.1-alpha.2 works
3.0.260311-beta works
3.0.260415-beta fails

I assume nitrojs/nitro#4108 broke the logic because for non-localhost routes isNitroRoute returns false while for localhost it returns true.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages