Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refused to execute script, strict MIME type checking is enabled?

Why am I getting this error in console?

Refused to execute script from 'https://www.googleapis.com/customsearch/v1?key=API_KEY&q=flower&searchType=image&fileType=jpg&imgSize=small&alt=json' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.

like image 914
rob.m Avatar asked Nov 13 '16 13:11

rob.m


People also ask

How do I fix strict mime check is enabled?

To Solve MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled ErrorJust make Sure Your File name and the name You are Using in Link Tag Both Are Same. For Example my File name is style. css Then My Link tag is Something like this:<link rel=”stylesheet” href=”style.


2 Answers

You have a <script> element that is trying to load some external JavaScript.

The URL you have given it points to a JSON file and not a JavaScript program.

The server is correctly reporting that it is JSON so the browser is aborting with that error message instead of trying to execute the JSON as JavaScript (which would throw an error).


Odds are that the underlying reason for this is that you are trying to make an Ajax request, have hit a cross origin error and have tried to fix it by telling jQuery that you are using JSONP. This only works if the URL provides JSONP (which is a different subset of JavaScript), which this one doesn't.

The same URL with the additional query string parameter callback=the_name_of_your_callback_function does return JavaScript though.

like image 87
Quentin Avatar answered Sep 21 '22 08:09

Quentin


In my case it was a file not found, I typed the path to the javascript file incorrectly.

like image 35
mruanova Avatar answered Sep 20 '22 08:09

mruanova