HTTPS与角$ HTTP不工作 [英] HTTPS with $http in Angular not working
问题描述
我使用的角度建立一个Facebook标签。我做了$ http请求的PHP页面上的同一个域。请求如下:
I'm building a Facebook Tab using Angular. I'm doing a $http request to a PHP page on the same domain. The request looks like this:
$http({
method: 'JSONP',
url: '/api?action=saveResult&points=' + state.points + '&callback=JSON_CALLBACK',
cache: false
});
该应用程序是配有HTTPS但是当我尝试运行在Facebook标签应用程序我碰到下面的混合内容错误:
The app is served with HTTPS but when I try to run the app in a Facebook tab I get the following mixed content error:
混合内容:在 https://example.com 页面加载了
HTTPS,但要求一个不安全的脚本
的http://example.com/api/?action=saveResult&points=2&callback=angular.callbacks._0'.
这一要求已被封锁;内容必须通过HTTPS提供。
Mixed Content: The page at 'https://example.com' was loaded over HTTPS, but requested an insecure script 'http://example.com/api/?action=saveResult&points=2&callback=angular.callbacks._0'. This request has been blocked; the content must be served over HTTPS.
我也试图把完整的URL使用$ HTTP方法HTTPS,但我仍然得到同样的错误。
I have also tried putting the full URL with HTTPS in the $http method, but I still get the same error.
推荐答案
我终于解开了它的方式是直接指向的URL php文件。
The way I finally solved it was to point the url directly to the php file.
$http({
method: 'JSONP',
url: '/api/index.php?action=saveResult&points=' + state.points + '&callback=JSON_CALLBACK',
cache: false
});
这还是很不清楚我为什么第一种方式没有工作。
It's still very unclear to me why the first way didn't work.
这篇关于HTTPS与角$ HTTP不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!