Skip to content Skip to sidebar Skip to footer

Resource Blocked Due To MIME Type?

For many years I have successfully included javscript files which are dynamically created. Here is an example: https://granadainfo.com/sups.php?locs=95 As you can see it loads OK.

Solution 1:

PHP defaults to Content-Type: text/html. If you aren't serving HTML, then you need to use the header() function to state what you are serving.

<?php
    header("Content-Type: application/javascript");

Solution 2:

The advanced support of A2 hosting eventually got back to me with a good answer. The following is based on what they said and it does solve the problem.

There is a simple solution.

For security reasons, we recently set "X-Content-Type-Options" to "nosniff" by default on all of our servers. If the option was not manually set in your ".htaccess" file, then the site just defaulted to whatever the server was using (nosniff). This is what was causing the error on the site.

Earlier in this ticket, you were told to unset the "X-Frame-Options" header mistakenly because that option is only for iframes. The actual header you needed to unset was "X-Content-Type-Options".

This is the line to add to the top of your .htaccess file.

Header always unset X-Content-Type-Options


Solution 3:

I agree with your answer.

In the end I have changed the filenames to .js and made .js parse with php like this in the .htacess file.

RewriteEngine on
AddHandler application/x-httpd-ea-php56 .php4 .php3 .php .phtml .htm .html .cgi .ics 
.js

Then I added this to the top of all the files

header('Content-Type: text/javascript');

It now works.

All efforts to solve the problem with X-Content-Type-Options in the .htacess file failed.


Post a Comment for "Resource Blocked Due To MIME Type?"