简体   繁体   English

Chrome 71将拒绝执行脚本,因为其MIME类型('text / x-js')无法执行

[英]Chrome 71 will refuse to execute script because its MIME type ('text/x-js') is not executable

I am facing an issue on Chrome 71 : in FireFox it works fine, also on Chrome < v71. 我在Chrome 71上遇到问题:在FireFox中,它在Chrome <v71上也能正常工作。 There was an announcement at Google that we should expect two small changes in our way of working with service workers and cache storage api . Google宣布将服务工作者缓存存储api一起工作,我们将期待两个小小的改变。 But the new version breaks my importScripts and I do not know how to solve it yet. 但是新版本破坏了我的importScripts,我还不知道如何解决它。

I got a file named pdfmake-worker-blob.js which makes an: 我得到了一个名为pdfmake-worker-blob.js的文件,该文件可以使:

importScripts('./pdfmake.min.js');
importScripts('./vfs_fonts.js');

onmessage = function(req) {

  pdfMake.fonts = {
      Courier: { normal: 'cour.ttf',bold: 'cour-bold.ttf' },
      Arial: { normal: 'arial.ttf',bold: 'arial-bold.ttf' }
  };

  try {
    var pdf = pdfMake.createPdf(req.data);
    pdf.getBlob(function(output) {
        postMessage(output);
    });
  } catch(err) {
    throw err;
  }
}

Then we create the worker in another service like this before using it: 然后,在使用它之前,我们在另一个服务中创建工作程序:

 var pdfmakeWorkerBlob = new Worker('scripts/pdfmake-worker-blob.js');

And you can see this in chrome debugger mode(let me remind you once again that the code works fine on firefox and chrome 70 and below I guess): 而且您可以在chrome调试器模式下看到这一点(我想再次提醒您,代码在firefoxchrome 70及以下版本上正常运行): 在此处输入图片说明

With the following messge in the console and my worker doesn't do his job anymore: 在控制台中出现以下消息后,我的工作人员不再做他的工作:

pdfmake-worker-blob.js:1 Deprecated: Future versions will refuse to execute script from ' http://myserver_name.company.com/application_name/scripts/pdfmake.min.js ' because its MIME type ('text/x-js') is not executable. pdfmake-worker-blob.js:1已弃用:将来的版本将拒绝从' http://myserver_name.company.com/application_name/scripts/pdfmake.min.js '执行脚本,因为它的MIME类型('text / x- js')不可执行。

I did not set this Mime type or any i just did an importscripts that is all. 我没有设置这种Mime类型,或者任何我只是做一个importscripts就是全部。 I hope it is clearer now. 我希望现在更加清楚。

For those who is facing the problem it is a well konown issue: " strict MIME type checking ". 对于那些正面临这个问题的人来说,这是一个众所周知的问题:“ 严格的MIME类型检查 ”。 Chrome enables strick mime type checking. Chrome启用了严格的mime类型检查。 There is ton of questions on stack over flow about it. 关于它的堆栈上有大量问题。 But it happens that it was still possible to avoid " strict MIME type checking " through worker api with importScripts. 但是碰巧,仍然可以通过具有importScripts的工作程序api避免“ 严格的MIME类型检查 ”。

For those who are still using chrome 70.0.3538.110 like me there is no strick mime type checking through the importScripts on the worker api. 对于像我这样仍在使用chrome 70.0.3538.110的用户,没有通过worker api上的importScripts进行严格的mime类型检查。 The new version of chrome fixes it. chrome的新版本已修复。 But it is still possible in firefox. 但是在Firefox中仍然有可能。 I reported this behaviour to mozilla in case it was not expected 我向Mozilla报告了此行为 ,以防万一

It was not clear for me but in our production machine our apache server has this mime type set: "text/x-js js" . 对我来说还不清楚,但是在我们的生产机器中,我们的apache服务器设置了这个mime类型: “ text / x-js js” I simply replace it with application "application/javascript" js instead or "text/javascript js" which is obsolete by the way. 我只是用应用程序“ application / javascript” js或“ text / javascript js”代替了它,不过这已经过时了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 资源被解释为脚本,但以MIME类型text / x-js传输 - Resource interpreted as Script but transferred with MIME type text/x-js 拒绝执行脚本,因为其 MIME 类型 (&#39;image/gif&#39;) 不可执行 - Refused to execute script because its MIME type ('image/gif') is not executable Webpack dev服务器抛出错误 - 拒绝执行脚本,因为它的MIME类型('text / html')不可执行 - Webpack dev server throws error - Refused to execute script because its MIME type ('text/html') is not executable 拒绝从“http://127.0.0.1:5500/”执行脚本,因为它的 MIME 类型(“text/html”)不可执行 - Refused to execute script from 'http://127.0.0.1:5500/' because its MIME type ('text/html') is not executable 将 jQuery 插件导入 Angular 2+ 拒绝执行脚本,因为其 MIME 类型('text/html')不可执行 - Importing jQuery plugin into Angular 2+ Refused to execute script because its MIME type ('text/html') is not executable 拒绝从 &#39;URL&#39; 执行脚本,因为它的 MIME 类型 (&#39;text/html&#39;) 不可执行,并且启用了严格的 MIME 类型检查 - Refused to execute script from 'URL' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled 拒绝从“ file_name.php”执行脚本,因为其MIME类型(“ text / html”)不可执行,并且启用了严格的MIME类型检查 - Refused to execute script from 'file_name.php' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled 拒绝执行脚本runtime.js,因为MIME类型不可执行 - Refused to execute script runtime.js because MIME type is not executable Angular 6:拒绝从“URL”执行脚本,因为它的 MIME 类型()不可执行,并且启用了严格的 MIME 类型检查 - Angular 6 : Refused to execute script from 'URL' because its MIME type( ) is not executable, & strict MIME type checking is enabled 拒绝执行脚本,因为它的 MIME 类型 ('application/gzip') 不可执行,并且启用了严格的 MIME 类型检查 - Refused to execute script because its MIME type ('application/gzip') is not executable, and strict MIME type checking is enabled
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM