【问题标题】:WebSharper - JQuery and HTTPS referenceWebSharper - JQuery 和 HTTPS 参考
【发布时间】:2016-08-22 07:38:50
【问题描述】:

将w#客户端页面部署到github页面后,出现如下错误:

Mixed Content: The page at 'https://aph5nt.github.io/websharper.amplifyjs/' was loaded over HTTPS, but requested an insecure script 'http://code.jquery.com/jquery-1.11.2.min.js'. This request has been blocked; the content must be served over HTTPS.(anonymous function) @ SampleApp.head.js:1
amplify.js:830 Uncaught ReferenceError: jQuery is not defined

是否有可能以某种方式修复此错误?

【问题讨论】:

    标签: jquery websharper


    【解决方案1】:

    快速浏览一下,问题在于 WebSharper 核心中通过 http 错误地引用了 jQuery:

    Namespace "WebSharper.JQuery.Resources" [
        Resource "JQuery" "http://code.jquery.com/jquery-1.11.2.min.js"
        |> fun r -> r.AssemblyWide()
    ]
    

    (https://github.com/intellifactory/websharper/blob/5c884e97fd3dba1102c10a85b171f672d0b3f637/src/stdlib/WebSharper.JQuery/Definition.fs#L1120)

    这会导致对 jQuery 的每个引用都会自动拉入上述资源,并且通过 https 服务的应用程序将无法加载它。

    在解决此问题之前,您可以覆盖 web.config 中对 jQuery 的引用以使用无协议 URL:

    <appsettings>
        <add key="WebSharper.JQuery.Resources.JQuery" value="//code.jquery.com/jquery-1.11.1.min.js" />
        ...
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2023-02-08
      • 2015-07-30
      • 2012-07-13
      • 2010-11-02
      • 1970-01-01
      • 2012-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多