app.ts won't load; CORS related?
Describe the bug
On a freshly spun up project, the http://localhost:300/src/js/app.ts won't load and throws a 500 error on Chrome. On Firefox, the console warning attributes the issue to be CORS related and a disallowed MIME type.
To reproduce
Steps to reproduce the behaviour:
- Spin up a fresh install of nystudio107/craft
- Check web inspector for warnings/errors. (refer to screenshots)
Expected behaviour
A clear and concise description of what you expected to happen.
Versions
Craft 3.8.10.2, Vite 1.0.30 Also tried using Craft 4.4.10.1, Vite 4.0.5
Screenshots
Chrome Inspector
Firefox Inspector
You're accessing the local site via https -- it's supposed to be accessed via http (no SSL), so you should be going to http://localhost:8000 in your browser.
If you're getting forcibly redirected to https, it's probably Chrome (or another browser) enforcing HSTS:
https://www.chromium.org/hsts/
Here's how to clear the HSTS settings:
https://www.ssl2buy.com/wiki/how-to-clear-hsts-settings-on-chrome-firefox-and-ie-browsers
Hi Andrew, I double checked and it seems I'm accessing the local site via http (without SSL) and I'm not being redirected to https. If you look at my prior screenshot, it'll actually show in the console "Navigated to http://localhost:8000/".
Just in case, I also tried to clear the HSTS settings for localhost and localhost:8000, but it doesn't show when you query for it in chrome://net-internals/#hsts.
I have an old version of your setup that works and still works properly (from Jan 2022) with an early version of Craft 3. But spinning up the latest project is throwing the issue.
Alright, I'll have a look. Sounds strange.
Potentially some clues: https://www.google.com/search?q=vite+was+blocked+because+of+a+disallowed+mime+type&rlz=1C5CHFA_enUS980US984&oq=vite+was+blocked+becau&aqs=chrome.0.0i512j69i57j0i390i650l2j69i60l2.3773j0j7&sourceid=chrome&ie=UTF-8
Yeah, Firefox logs that the issue is with a disallowed MIME type (“”). Safari just throws a 500 error without more details.
Someone mentioned a similar issue and said that changing the vite internal dev server from ‘http://vite:3000/’ to ‘http://localhost:3000/‘ fixed a similar issue. I tried that, but that didn’t work.
Would any changes after Craft 3.6 have contributed to the issue? The old install is running Craft 3.6 with settings that seem largely the same as the current version of the project. It works swimmingly.