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.
I usually put them into the head of my html document like this.
script type="text/javascript" src="https://granadainfo.com/sups.php?locs=95"
/script
In the last few days they have stopped working.
The error message from firefox debugger console is the following.
The resource from “https://granadainfo.com/sups.php?locs=95” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
I use a2 web hosting. They must have made some change in configuration to make it stop working.
It may be that I can get over this problem with a line in the .htaccess file.
A2 hosting suggested this line but it does not work. Header always unset X-Frame-Options
The problem only happen when there is a get request. ie ?locs=95
There is no problem with static files.
I tried changing the file name to .js and changed the .htaccess file to parse .js as php but it makes no difference.
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");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With