【问题标题】:MIME type issue in JavaScriptJavaScript 中的 MIME 类型问题
【发布时间】:2020-11-10 02:37:04
【问题描述】:

我在一个网站工作。我的<head> 如下所示。

<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">

    <script type="text/javascript" src="http://github.com/mrdoob/three.js/blob/dev/build/three.min.js"></script>
    <script type="text/javascript"
        src="http://github.com/pchen66/panolens.js/blob/master/build/panolens.min.js"></script>

    <script>
        const panorama = new PANOLENS.ImagePanorama('./images/project.jpg');
        const viewer = new PANOLENS.Viewer();
        viewer.add(panorama);
    </script>
</head>

但我收到错误The resource from “https://github.com/pchen66/panolens.js/blob/master/build/panolens.min.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

为什么我会看到这个错误?

【问题讨论】:

  • 因为 github 不希望你链接到文件......它被设置为不同的内容类型。

标签: javascript mime-types src


【解决方案1】:
  1. 使用 rawgit.com 代替 github.com
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">

    <script type="text/javascript" src="https://rawgit.com/mrdoob/three.js/dev/build/three.min.js"></script>
    <script type="text/javascript"
        src="https://rawgit.com/pchen66/panolens.js/master/build/panolens.min.js"></script>

    <script>
        const panorama = new PANOLENS.ImagePanorama('./images/project.jpg');
        const viewer = new PANOLENS.Viewer();
        viewer.add(panorama);
    </script>
</head>

【讨论】:

    猜你喜欢
    • 2019-11-01
    • 2017-04-24
    • 1970-01-01
    • 2016-09-10
    • 1970-01-01
    • 2011-01-25
    • 2018-06-09
    • 2015-01-11
    • 1970-01-01
    相关资源
    最近更新 更多