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
...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 solutionsThe error message you reported shows that you want to access api.dribbble.com from localhost
This way test.dribbble.com can access api.dribbble.com🎜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 localThen set the test domain name in the header of the php file to access
Access-Control -Allow-Origin: "test.dribbble.com"
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