/src/main.tsx:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.Here my java react code found this eror I was trying to resolve this issue but I cant. Please solve this issue here is my vite.config.ts code:import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(dirname, 'src'), // Resolve '@' to 'src' folder
},
},
server: {
open: true, // Open the browser automatically
strictPort: true, // Ensure strict port matching
hmr: {
protocol: 'ws', // WebSocket for hot module replacement
host: 'localhost',
},
},
esbuild: {
keepNames: true, // Retain function and variable names in production build
},
build: {
sourcemap: true, // Enable source maps in production builds
},
base: '/', // Ensure base path is correct for production builds
});
Index.html code:<!doctype html>
<br>
import RefreshRuntime from "/@react-refresh"<br>
RefreshRuntime.injectIntoGlobalHook(window)<br>
window.$RefreshReg$ = () => {}<br>
window.$RefreshSig$ = () => (type) => type<br>
window.</strong>vite_plugin_react_preamble_installed__ = true<br>
<script type="module" src="/@vite/client"></script>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fuad Portfolio</title>
.I will also upload my project structure please solve this problem. when I deploy and host the service it shows this error. but my PC also runs without any issues.
Top comments (0)