I'm having an issue in serving a vite
app. I'm building the app using the following command:
vite build --base=/registration-form/
and serving the app with
serve -s dist
But I'm getting the following error in the browser console and all the .js
files are HTML files.
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.
More context:
I'm using serving in production with pm2
, serve
& nginx
. This is my startup script:
pm2 start "serve -s -p [PORT] dist" --name registration-form
and this is the part of my nginx.conf
that handles this route:
location /ideathon-registration/ {
http://[HOST]:[PORT];
}
How do I solve this?
Vite version: ^2.3.8
Node version: 14.17.1
Local OS: Linux Mint 20.04
Server OS: Ubuntu 18.04