I am seeing the following error in the browser when I launch my web page for production.
Failed to load module script: Expected a JavaScript 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.
My code is Reactjs and I am serving it from nodejs
URL = https://qaentry.domain.com/It
VITE package.json
"scripts": {
"dev": "vite --base=/pmo",
"build": "tsc && vite build --base=/pmo",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite --base=/pmo preview"
},
APP.tsx
const router = createBrowserRouter([
{
path: "/pmo",
element: <LandingPage />,
}
])
client path
- client
---dist
-----assets
------ index--_a54pe.js
-----index.html
SERVER.js
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "../../client/dist/index.html"));
});
VITE congfig
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
build:{
outDir: "dist"
}
})
It works using localhost but not in production. Can you give me some hints for solving this issue