gpt4 book ai didi

angularjs - 应用实现 SSL : Mixed Content: This request has been blocked; the content must be served over HTTPS"后 GET 请求抛出错误

转载 作者:可可西里 更新时间:2023-11-01 15:17:40 24 4
gpt4 key购买 nike

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.

我们有这个在后端使用 Flask 运行的 Angular 网络应用程序。在我们实现 SSL 之前,一切都运行良好。之后,我们到处都会收到这个奇怪的错误。

现在,我的 dashboard.js 中的 $http.get 请求肯定会在下面的代码中调用“https://api.example.com/inventory/10”,但错误是声称我们正在尝试请求“http”。

$http.get($rootScope.baseUrl+'/inventory/' + item.id)

其中 rootScope.baseUrl 是“https://api.example.com ”。

这真的很奇怪,因为一些 GET 请求正在从我们的 Web 应用程序传递到我们的后端,但有些请求却抛出了这个奇怪的错误。

这是在 chrome 控制台的“网络”选项卡中出现错误的 header 。

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

最佳答案

这是一个奇怪的案例,归结为从修复所有问题的 URL 末尾删除正斜杠。不知何故,每当我们在 Angular 中使用 $http 发出 GET 请求时,如 baseurl + inventory.id + "/",它会发出 http 请求,但一旦删除斜杠,它就会正确发出 https 请求。

还是很迷茫

关于angularjs - 应用实现 SSL : Mixed Content: This request has been blocked; the content must be served over HTTPS"后 GET 请求抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30538209/

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