I have a react typescript vite application and the build and run commands are as follows:
"build": "tsc && vite build",
"start:prod": "serve -s ./dist -p 8080"
It works just fine locally, without any problems, but in the cloud (using openshift) it gives me an error message:
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.
I have an additional route for this microservice in openshift but I have to set the base in the vite.config.ts to be './' then it successfully get the files from the server but with an improper content-type.
I have also set the resolve extensions in the vite.config.ts but it didn't help.
Any ideas what could have caused this error?
You need to configure your backend API with a
Content-Typeheader astext/javascripton this file (or allYou can see it with Chrome debug, panel Network to look how the ressource is requested.