I’m getting this 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.
This happens when I try to access my Vite preview over my LAN at: http://192.168.x.x:3000/ from any Windows machine on my network.
It works correctly without errors on Linux / Android / IOS over the same network.
My vite.config.js and index.html page are as follows:
export default {
root: "./src/",
publicDir: "../public/",
build: {
outDir: "../dist/",
emptyOutDir: true,
reportCompressedSize: true,
},
server: {
port: 3000,
host: true,
open: false,
},
worker: {
format: 'es',
},
base: './',
};
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Site Header</title>
<link rel="stylesheet" href="style.css" />
<script type="module" src="main.js"></script>
</head>
<body>
<header>
<h1>Site Header</h1>
</header>
<section id="mainSection">
<div id="canvasContainer"></div>
</section>
<footer>Site Footer</footer>
</body>
</html>
For some reason, it just loads the bare HTML, no CSS and no JS. It generates that error trying to load the JS. At this point I’m not sure what to try; as far as I can tell everything is configured correctly.



