如何在AngularJS中使用HTTPS? [英] How can I use HTTPS in AngularJS?
问题描述
我正在使用AngularJS, $ resource
& $ http
并使用 apis
,但由于安全原因,我需要发出HTTPS请求(在HTTPS下工作)协议)。
I am using AngularJS, $resource
& $http
and working with apis
, however due to security reason I need to make an HTTPS request (work under the HTTPS protocol).
在AngularJS中使用 https
的方法是什么。感谢您的帮助。
What's the way to use https
in AngularJS. Thanks for your help.
推荐答案
使用 $ http
api通常会:
$http.get('/someUrl').success(successCallback);
如果你的应用程序是通过HTTPS提供的,那么你正在进行的任何调用都是针对同一个主机/端口等也通过HTTPS。
if your app is being served over HTTPS then any calls you are making are to the same host/port etc so also via HTTPS.
如果您对请求使用完整的URI,例如 $ http.get('http://foobar.com/somePath')
然后您必须更改您的URI才能使用 https
If you use the full URIs for your requests e.g. $http.get('http://foobar.com/somePath')
then you will have to change your URIs to use https
这篇关于如何在AngularJS中使用HTTPS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!