angular.js - How does angularjs cross domains?
迷茫
迷茫 2017-05-15 17:01:31
0
5
534

I want to request data from Dribbble using the localhost address

Report
XMLHttpRequest cannot load https://api.dribbble.com/v1/shot. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 404.

I just think it is a cross-domain problem. How can I solve it?

He gave Client ID, Client Access Token...I don’t know how to use it...Please answer QAQ

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(5)
Peter_Zhu

...I have never used angularjs but I took a look and its request is also based on XMLHttpRequest. So how can it be cross-domain? If you want to cross-domain, please directly look for the axjx cross-domain method.

伊谢尔伦

You can use node to forward requests

大家讲道理

That domain is different from your localhost, so you are prompted with this error. There are two methods. Let cors be turned on in the background and set this header Access-Control-Allow-Origin: * to allow requests from all domains. Or use JSONP, or find other solutions

世界只因有你

The error message you reported shows that you want to access api.dribbble.com from localhost
These are two different domains, so there are cross-domain problems.
How to use CROS:
php in api.dribbble.com Set Access-Control-Allow-Origin: * in the file header to allow access from all domains. Access-Control-Allow-Origin: *,就可以允许所有的域访问了。
但是这样做存在安全问题,推荐你在本地配置一个环境,用host把一个测试域名例如test.dribbble.com指向本地
然后在php文件的header里面设置这个测试域名可以访问Access-Control-Allow-Origin: "test.dribbble.com"However, there are security issues with this. It is recommended that you configure an environment locally and use host to point a test domain name such as test.dribbble.com to the local
Then set the test domain name in the header of the php file to access Access-Control -Allow-Origin: "test.dribbble.com"

This way test.dribbble.com can access api.dribbble.com🎜
阿神

If you just want to run it locally, then use your chromebrowser and enable cross-domain settings. http://blog.csdn.net/notepaper/article/details/8565524

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template