The browser intercepts the cross-origin request processing method-Firefox reports an error. The same-origin policy cannot read remote resources on xxx.

Source: Internet
Author: User
Tags certificate fingerprint

CORS can be used for cross-origin requests with different domain names.

1) place the following files in the requested project root directory (Root ):

Crossdomain. xml

  1. [HTML]View plaincopyprint?
    1. <? XML version = "1.0"?>
    2. <! Doctype cross-domain-policy system "./cross-domain-policy.dtd">
    3. <Cross-domain-Policy> <site-control permitted-Cross-Domain-policies = "all"/>
    4. <Allow-access-from domain = "*"/>
    5. <Allow-http-request-headers-from domain = "*" headers = "*"/>
    6. </Cross-Domain-Policy>

Cross-domain-policy.dtd

  [HTML]View plaincopyprint?
  1. <? XML version = "1.0" encoding = "ISO-8859-1"?>
  2. <! -- Adobe DTD for Cross-Domain Policy files -->
  3. <! -- Copyright (c) 2008-2009, Adobe Systems Inc. -->
  4. <! Element Cross-Domain-Policy (site-control ?, Allow-access-from *, allow-http-request-headers-from *, allow-access-from-identity *)>
  5. <! Element site-control empty>
  6. <! ATTLIST site-control permitted-Cross-Domain-policies (all | by-Content-Type | by-ftp-filename | master-only | none) # required>
  7. <! Element allow-access-from empty>
  8. <! ATTLIST allow-access-from domain CDATA # required>
  9. <! ATTLIST allow-access-from to-ports CDATA # implied>
  10. <! ATTLIST allow-access-from secure (true | false) "true">
  11. <! Element allow-http-request-headers-from empty>
  12. <! ATTLIST allow-http-request-headers-from domain CDATA # required>
  13. <! ATTLIST allow-http-request-headers-FROM headers CDATA # required>
  14. <! ATTLIST allow-http-request-headers-from secure (true | false) "true">
  15. <! Element allow-access-from-Identity (signatory)>
  16. <! Element signatory (certificate)>
  17. <! Element certificate empty>
  18. <! ATTLIST certificate fingerprint CDATA # required>
  19. <! ATTLIST certificate fingerprint-algorithm CDATA # required>
  20. <! -- End of file. -->

Test that the two XML files can be accessed from http: // domain: Port/crossdomain. xml.

2) responseheader must be added to the target to be returned.Access-control-allow-Origin

Response. setheader ("Access-control-allow-Origin","*");

* Can be the domain name of the requester.

Reference: http://blog.csdn.net/hereiskxm/article/details/32093675

 

The browser intercepts the cross-origin request processing method-Firefox reports an error. The same-origin policy cannot read remote resources on xxx.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.