【发布时间】:2015-03-27 15:56:41
【问题描述】:
在网页上安装 SSL 证书后,我遇到了使用 https 服务的页面需要使用 ajax 的 http 端点的问题。 我正在使用restangular,并将基本网址更改为https。
var uri = location.protocol + "//" + location.host;
RestangularProvider.setBaseUrl(uri);
有趣的是,当我在 chrome 开发人员工具中看到请求时,我看到了
Request URL:https://theaddress.com/api/endpoint
Request Headers
Provisional headers are shown
Accept:application/json, text/plain, */*
Referer:https://theadress.com/somepage
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36
X-Requested-With:XMLHttpRequest
所以请求应该是 https 的,但我仍然得到:
Mixed Content: The page at 'https://theaddress.com/somepage' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://theadress.com/api/endpoint'. This request has been blocked; the content must be served over HTTPS.
另外我应该提到,这发生在 prod 服务器上,但在我的本地测试中,在我使用包含 https 的基本 url 后它工作正常(我有自签名的 ssl 证书)。
可能是什么问题?
【问题讨论】:
-
https请求的响应是什么?也许有一个 HTTP 302 重定向到http端点? -
这是带有 200 响应的常规 json。没有重定向。
标签: javascript angularjs https restangular