Forums

MIME type ('text/html') is not executable, and strict MIME type checking is enabled

Good day,

I have a basic react project which I am serving from a Django app. I have a vanilla react (dev) environment setup using babel, webpack. Webpack generates a "main.js" file which is referenced in my index.html enclosed in script tags with type "application/javascript".

When running the app locally I have no issues or warnings.

When deploying to pythonanywhere (firefox) I get: "Refused to execute script from 'https://scorescr.pythonanywhere.com/static/main.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled."

I am guessing that the issue is to do with the fact that I am serving the file from the web app itself and returning a mime type of html. (Opera and safari produce similar errors).

Can one configure webpack to set a mime type for the file ? (I cant find any info on this), OR, Do something in django to serve the file with the mime type "application/javascript", OR, am I just missing something really obvious...

Any advise would be appreciated. Thank you.

You're getting that message because you are not serving the file so, instead of the script, your page is getting a 404 error. See https://help.pythonanywhere.com/pages/StaticFiles/ and https://help.pythonanywhere.com/pages/DebuggingStaticFiles/

Thank you, I am going to investigate.

Embarrassed much. Thank you Glenn. Very much.

Glad you got that working!