混合内容:在 https://www.example.com/dashboard 是该页面 加载通过HTTPS,但要求一个不安全的XMLHtt prequest端点 http://api.example.com/inventory/10/ 。这一要求已被封锁; 内容必须通过HTTPS提供。
我们有一个与瓶在后端运行此角的Web应用程序。一切工作正常,直到我们实现SSL。后来,我们不断收到这个奇怪的错误比比皆是。
现在,在我的dashboard.js $ http.get要求肯定是叫 https://开头的API .example.com的/存货/ 10 下code,但错误声称,我们正在试图请求HTTP代替。
$ http.get($ rootScope.baseUrl +'/存货/+ item.id)
其中rootScope.baseUrl是 https://api.example.com 。
这真的很奇怪,因为一些GET请求是从我们的Web应用程序,以我们的后端经历,但有些请求被抛出这个奇怪的错误。
下面是在Chrome中控制台我们的网络选项卡得到一个错误的标题。
请求URL: https://api.example.com/inventory/10 请求头 临时标题显示接受:应用/ JSON,纯文本/,的 / 的 原产地: https://www.example.com 引用者: https://www.example.com/dashboard
解决方案这是来到了从URL固定一切的结束卸下斜线一个奇怪的情况。不知怎的,每当我们在角像baseURL时提出使用$ HTTP GET请求+ inventory.id +/,它将使一个http请求,但只要删除该斜线,它会正确地进行HTTPS请求。
不过这么糊涂
Mixed Content: The page at 'https://www.example.com/dashboard' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.example.com/inventory/10/'. This request has been blocked; the content must be served over HTTPS.
We have this Angular web app that runs with Flask on the back-end. Everything was working fine until we implemented SSL. Afterwards, we keep getting this strange error everywhere.
Now, the $http.get request in my dashboard.js is definitely calling "https://api.example.com/inventory/10" in the code below and yet the error is claiming that we are trying to request "http" instead.
$http.get($rootScope.baseUrl+'/inventory/' + item.id)
where rootScope.baseUrl is "https://api.example.com".
It's really weird because some GET requests ARE going through from our web application to our back-end, but some requests are throwing this weird error.
Here's the header that gets an error in our Network tab of the console in chrome.
Request URL:https://api.example.com/inventory/10 Request Headers Provisional headers are shown Accept:application/json, text/plain, / Origin:https://www.example.com Referer:https://www.example.com/dashboard
解决方案
It was a weird case that came down to removing a forward slash from the end of a URL fixing everything. Somehow, whenever we made a GET request using $http in Angular like baseurl + inventory.id + "/", it would make a http request but as soon as remove that slash, it would make the https request correctly.
Still so confused