Using Access-control-allow-origin to troubleshoot cross-domain

Source: Internet
Author: User

What is a cross-domain

When two domains have the same protocol (such as HTTP), the same port (for example, 80), the same host (for example, www.google.com), then we can assume that they are the same domain (protocol, domain name, port must be the same).

Cross-domain refers to the protocol, domain names, port inconsistencies, for security reasons, cross-domain resources are not interactive (such as the general situation of cross-domain JavaScript can not interact, of course, there are many solutions for cross-domain)

Access-control-allow-origin

Access-control-allow-origin is a policy defined in HTML5 that addresses the cross-domain of resources.

He is returning the response header with the Access-control-allow-origin identity through the server to resolve cross-domain permissions issues for the resource.

Using the method, add Access-control-allow-origin in response, for example

Access-control-allow-origin:www.google.com

Www.google.com is the domain name to access, set according to the actual situation.

can also be set to * indicates that the resource can be used by anyone

Access-control-allow-origin: *

If the resource is an HTML page, you can set the

<meta http-equiv= "Access-control-allow-origin" content= "*" >

  

Using Access-control-allow-origin to troubleshoot cross-domain

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.