Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to address error "Did not load script at 'script name' because non script MIME types are not allowed when 'X-Content-Type: nosniff' is given

I have a fairly simple Angular 1.x app that was working fine until i upgraded to Safari 11. Now, it doesn't work because almost all of the js files are blocked.

The same was true for CSS files, but removing the "rel" attribute and adding type="text/css" fixed the CSS issues.

For the JS files, I've made sure to add type="text/javascript" to the script tags. I also just tried adding ./ to the beginning of the src's for giggles and they still won't load.

Does anyone know how to fix this?

Thanks, Wayne

like image 787
Wayne F. Kaskie Avatar asked Nov 14 '17 14:11

Wayne F. Kaskie


People also ask

How do I change the MIME type of a file?

In the Connections pane, go to the site, application, or directory for which you want to add a MIME type. In the Home pane, double-click MIME Types. In the MIME Types pane, click Add... in the Actions pane. In the Add MIME Type dialog box, add the file name extension and MIME type, and then click OK.

What is blocked by a disallowed MIME type text HTML angular?

This may be because the server-side recognition is buggy or the JS file is non-existent (and the server does not send a 404 status code?) or there is no js in it. Because of that, it sends the Content-Type text/html . The browser sees the content type, thinks this is no css and does not allow it.

What is MIME type error?

If a web server or application reports an incorrect MIME type for content (including a "default type" for unknown content), a web browser has no way of knowing the author's intentions. This may cause unexpected behavior. Some web browsers, such as Internet Explorer, try to guess the correct MIME type.


1 Answers

I want to just delete the question but I hope maybe this answer will still be helpful to someone.

So, my problem was actually that I had a bad clone of my project and it was missing files!

However, for anyone having the same issue:

ensuring that type="text/css" for stylesheets and type="text/javascript" did fix the issue. (for the files that actually existed)

like image 67
Wayne F. Kaskie Avatar answered Oct 28 '22 11:10

Wayne F. Kaskie