gpt4 book ai didi

javascript - 如何从 HTTPS 服务器请求 HTTP 服务器的 javascript 文件

转载 作者:行者123 更新时间:2023-11-28 22:52:51 26 4
gpt4 key购买 nike

好吧,我有一个通过 HTTPS 运行的应用程序,并且有从通过 HTTP 运行的服务器加载一些 javascript 文件的请求(这些 javascript 文件没有 HTTPS 选项),显然,我得到了这个错误:

Mixed Content: The page at 'https://myapplication.url.com/ was loaded over HTTPS, but requested an insecure script 'http://another.application/file.js'. This request has been blocked; the content must be served over HTTPS.

我在 SO 找到的解决方案是:而不是请求 http://another.application/file.js ,有人建议删除 http:,留下 //another.application/file.js。它不起作用。它尝试从 HTTPS 请求,但 file.js 没有 HTTPS 选项。

我刚刚在这里阅读了一些相关主题:

Request to a json resource from an http page to an https server

Downloading files from an http server in python

HTTP Request originated from HTTP Server

但是,不幸的是,他们都没有给我线索。有人已经收到此错误吗?如何解决?

我不知道这是否重要,但我使用的是 tomcat6、java7,当我尝试将文件包含在 index.html 中时出现问题:

这是我使用的代码:

script type="text/javascript" src="http://another.application/file.js"

最佳答案

据我所知,没有客户端解决方案。

您可以在您的服务器上设置代理,以便可以通过您的服务器 (https) 请求文件。但是,也许将该文件复制到您的服务器并从那里提供服务(如果它是静态的)会更容易。

或者,如果您使用 CDN,则可以将其设置为包括来自其他(仅 http)服务器的那些文件,但 CDN 通过 https 为它们提供服务。

关于javascript - 如何从 HTTPS 服务器请求 HTTP 服务器的 javascript 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35059790/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com