I want to request data from Dribbble using the localhost address
ReportXMLHttpRequest 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
天蓬老师2017-05-15 17:03:31
...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.
大家讲道理2017-05-15 17:03:31
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
世界只因有你2017-05-15 17:03:31
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"
阿神2017-05-15 17:03:31
If you just want to run it locally, then use your chrome
browser and enable cross-domain settings. http://blog.csdn.net/notepaper/article/details/8565524