Cross-origin request in javascript-js

Source: Internet
Author: User
I have added the header (& quot; Access-Control-Allow-Origin: * & quot;); To the backend ;);, but why does the {code...} still appear when the front-end uses js requests ...} I have added header("Access-Control-Allow-Origin:*");But why does the front-end still appear when using js requests?

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://nichijou.org/x. (Reason: CORS header 'Access-Control-Allow-Origin' missing). Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://nichijou.org/x. (Reason: CORS request failed).

Reply content:

I have addedheader("Access-Control-Allow-Origin:*");But why does the front-end still appear when using js requests?

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://nichijou.org/x. (Reason: CORS header 'Access-Control-Allow-Origin' missing). Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://nichijou.org/x. (Reason: CORS request failed).

  1. Many browsers do not support this function.*To setAccess-Control-Allow-OriginThe normal practice isheader("Access-Control-Allow-Origin:".$_SERVER['HTTP_HOST']);

  2. If you want to transmit cookiesAccess-Control-Allow-Credentials: trueThis header is used. Specific can see the document: https://developer.mozilla.org/en-US/docs/Web/HTTP/Server-Side_Access_Control

Which browsers are listed in the version number?

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.