[Solved]Refused to execute script because it's MIME type is not executable
Hi,
We are migrating from Webfocus 8010 to Webfocus 8204. We have certain fex files which are being called within an HTML. These fex files have JS embedded in it and it is failing to execute. Here's an example, below script(checkaccess.fex) is setting the value of variable check. This fex is being called within the html page and the value of check is being referred in another JS inside the HTML page. But it fails to run with the error: "run.bip?BIP_REQUEST_TYPE=BIP_LAUNCH&BIP_folder=IBFS%3A%2FWFC%2FRepository%2FOPERA%2FStaffing_Analysis_Suite%2F&BIP_item=flexibility_index.htm:1 Refused to execute script from '*****************BIP_item=CheckAccess.fex' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled."
-SET &ECHO = ALL
-IF &&EXTRASALLOWED CONTAINS 'StaffingAnalysis' THEN GOTO ACCESS;
-NOACCESS
-HTMLFORM BEGIN
var check = 'NO';
-HTMLFORM END
-GOTO DONE
-ACCESS
-HTMLFORM BEGIN
var check = 'YES';
-HTMLFORM END
-DONE
The difference I notice between the 8010 version and 8204 version is in the response headers.
I am getting "X-Content-Type-Options: nosniff" in the 8204 version and I believe this is causing the issue. However, i have not been able to find where this is being set. We are ussing IIS10 for SSO, Tomcat 8 and Webfocus 8204.This message has been edited. Last edited by: Kartik Katyal,
WebFOCUS 8010,8204 Windows
July 24, 2019, 05:05 PM
Waz
I think I would open a case with TechSupport on this one.
Although I have seen the mime type issue before somewhere.
How are you running the CheckAccess.fex ?
Can you post a snippet of code ?
Waz...
Prod:
WebFOCUS 7.6.10/8.1.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!
July 25, 2019, 01:32 AM
Kartik Katyal
Calling it withing the script tag in our html and then utilising the output in a JS function.
<script src="/ibi_apps/run.bip?BIP_REQUEST_TYPE=BIP_LAUNCH&BIP_folder=IBFS%253A%252FWFC%252FRepository%252FOPERA%252FStaffing_Analysis_Suite&BIP_item=CheckAccess.fex"></script>
<script type="text/javascript">
function checkaccess()
{
if (check == 'NO')
{
window.location.href = "/ibi_apps/run.bip?BIP_REQUEST_TYPE=BIP_LAUNCH&BIP_folder=IBFS%253A%252FWFC%252FRepository%252FOPERA%252FCommon_Replicated_Objects&BIP_item=No_Access_page.htm";
}
}
</script>
WebFOCUS 8010,8204 Windows
July 25, 2019, 04:46 PM
Waz
Try adding type="text/javascript" to your call.
e.g.
<script type="text/javascript"...
Waz...
Prod:
WebFOCUS 7.6.10/8.1.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!
July 26, 2019, 01:42 AM
Kartik Katyal
Tried already but that didn't help. It kept giving the same error message.
WebFOCUS 8010,8204 Windows
July 26, 2019, 01:45 AM
Kartik Katyal
I think it is validating the type with the actual extension of the file that are being called, because it doesn't error out for the .js files.
Also it doesn't error out if I give the fex files an extension of "text/plain" but then it doesn't resolve var check = "Yes" as javascript.
Wonder if it's something in the redirection settings that needs to be changed.
WebFOCUS 8010,8204 Windows
July 28, 2019, 05:11 PM
Waz
What browser are you having the issue on ?
I was going to suggest adding "SET HTMLFORMTYPE = JS" to your fex.
This will remove any comments/execution run text from the returned text.