search

Home  >  Q&A  >  body text

angular.js - How does angularjs cross domains?

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

迷茫迷茫2779 days ago541

reply all(5)I'll reply

  • 天蓬老师

    天蓬老师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.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-15 17:03:31

    You can use node to forward requests

    reply
    0
  • 大家讲道理

    大家讲道理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

    reply
    0
  • 世界只因有你

    世界只因有你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"

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

    reply
    0
  • 阿神

    阿神2017-05-15 17:03:31

    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

    reply
    0
  • Cancelreply