Issue with incorrect MIME type/404

I have a simple script on my Astro site located at ‘example.com/scripts/contactmodal.js’ This script toggles a contact popup with contact information. It works fine locally, but does not work when pushed to Cloudflare pages. It WAS working as of a week or two ago (not sure when it stopped), and now I am getting errors saying the MIME type does not match, OR 404 errors, OR both at the same time (depending on what I am changing to test). My site is extremely simple, so I am a bit baffled. It only has like 20 pages. All paths are correct (I have checked like 50 times and so has ChatGPT), and I do not have any caching rules, page rules, or HTSTS enabled. I have tried purging my cache. This seems to be a somewhat common sporadic bug over on the Cloudflare community support forum. I’ve tried manually setting my content-type to application/javascript using page rules, or ‘_headers’. That is successfully st changing the MIME type and getting rid of the MIME error, and I even get a 200 status code, but the script does not execute. I have infinity-checked that this is not user related error. The script WAS executing perfectly fine before. I know the issue is not with the script, as it works fine locally. So I am stumped. The paths are clearly all fine if it works locally, as is the script. And setting the MIME type manually does not get it to execute correctly, but does remove the errors. The only other thing I see is that Firefox throws an error in the network panel saying “NS_ERROR_CORRUPTED_CONTENT”. I have no idea what that means even after researching it for a bit. Can anyone help? Happy to provide as much information as necessary.
2 Replies
omnitechie
omnitechieOP4mo ago
I FINALLY fixed this issue and the script is now working. Leaving this answer here for anyone else who finds it, maybe the Cloudflare team can also have a look because it was very simple: After trying everything, scanning for incorrect paths, stepping through with the debugger, clearing caches, setting headers manually, on a whim I changed the name of the file. I previously thought of this so to test I changed it from “ContactModal” to “contactmodal” thinking any case changings would be enough to trigger/flip any errors related to paths, since it would register as a fresh path. This did not happen, so I figured it was not the issue. However, on a whim I changed the name to be completely unique, from “contactmodal” to “contactoptionsmodal”. And voila, it works. @Cloudflare (Server Owner) pinging you because maybe you can take this to your QA team and resolve the root bug. It seems to be related to how casing of paths are resolved during production, maybe involving the production build cache?
Flare
Flare4mo ago
Please do not ping community members for non-moderation reasons. Doing so will not solve your issue faster and will make people less likely to want to help you.
Want results from more Discord servers?
Add your server