Is it possible to specify the MIME type of a PHP file as application/javascript? I have a PHP file that outputs some JavaScript. When strict MIME type checking is enabled, the browser reports an error:
"Refused to execute script from *.php' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled."
Adding this to the PHP file doesn't help:
header("Content-type: application/javascript");
Here is my code:
<?
header('Content-Type: application/javascript');
include ("../admin/config.php");
include ("../custom_functions.php");
?>
var availableTags = ["BBCD"
<?
$prods=decode_prods();
foreach($prods as $key=>$val){
?>
, "
<?
$prods[$key][name] = preg_replace("/(\015\012)|(\015)|(\012)/","",$prods[$key][name]);
trim($prods[$key][name]);
$prods[$key][name]= str_replace("&", "and", $prods[$key][name]);
$prods[$key][name]= str_replace('"', '', $prods[$key][name]);
echo $prods[$key][name];
?>
"
<? } ?>
];
I tried adding this to .htaccess after reading this post - but it didn't help.
<Files /js/auto.php>
AddType application/javascript .js
</Files>
application/javascriptastext/javascriptis deprecated. I don't see why this would cause it but worth a try.