I try to deploy my app on Heroku.
My stack:
Backend: Express + Mongodb + Typescript
Frontend: Express + Vanilla JS (Single Page App)
Backend was deployed and working fine, problem is with Frontend. I wish I had used React, because with React I would know what to do. Problem is Vanilla JS. I must say that everything is working on my localhost, so problem exist after Heroku deployment.
In my index.html I have this line:
<script type="module" src="/static/javascript/index.js"></script>
And I see on Heroku app html from index.html, no css and in console that error: 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 think this is because Heroku try to go to localization https://my-app.herokuapp.com/static/javascript/index.js. How to tell Heroku to treat this path like a subfolder with module, not like localization to go?
When I work with React I tell in package.json to build frontend npm run build, what is substitution for this in Vanilla JS? How to say Heroku that this is Vanilla JS and build this?