How does Access-Control-Allow-Origin header work

0 votes

Until now my understanding of its semantics is:

  • A client downloads javascript code MyCode.js from http://siteA - the origin.
  • The response header of MyCode.js contains Access-Control-Allow-Origin: http://siteB, I thought it can cross-origin references with the other site.

I referred to Cross-origin resource sharing and understood that all I knew was wrong, I studied other articles but still, I didn't understand how to use this header. How do I enable the javascript code downloaded from site A to access resources on site B using this header?

May 11, 2022 in Java-Script by Kichu
• 19,040 points
851 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java-Script

0 votes
1 answer

Error:No Access-Control-Allow-Origin header is present on the requested resource node.js

Hello @kartik, My guess is that you're serving ...READ MORE

answered Jun 8, 2020 in Java-Script by Niroj
• 82,840 points
4,655 views
0 votes
1 answer

Error:Origin is not allowed by Access-Control-Allow-Origin

Hello @kartik, The easiest way to handle this ...READ MORE

answered Jun 18, 2020 in Java-Script by Niroj
• 82,840 points
8,948 views
0 votes
1 answer

Error:Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers

Hello @kartik, Access-Control-Allow-Headers does not allow * as accepted value. Instead of ...READ MORE

answered Jul 6, 2020 in Java-Script by Niroj
• 82,840 points
2,438 views
0 votes
1 answer

How can we access PHP variables in JavaScript or jQuery rather than <?php echo $variable ?>

Hello @kartik, You can also use json_encode for ...READ MORE

answered Apr 29, 2020 in Java-Script by Niroj
• 82,840 points

edited Oct 7, 2021 by Sarfaraz 8,688 views
0 votes
1 answer

How to access PHP session variables from jQuery function in a .js file?

Hello, You can produce the javascript file via ...READ MORE

answered Apr 29, 2020 in Java-Script by Niroj
• 82,840 points
12,926 views
0 votes
1 answer

CORS in AWS API Gateway + AWS Lambda

You could try downloading the AWS APIG ...READ MORE

answered Oct 9, 2018 in AWS by Priyaj
• 58,020 points
4,082 views
0 votes
0 answers

Response to preflight request doesn't pass access control check

I called a REST API on Amazon ...READ MORE

May 7, 2022 in Java-Script by narikkadan
• 63,600 points
1,804 views
0 votes
0 answers

Why does my JavaScript code receive a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error, while Postman does not?

I'm attempting to provide authorisation using JavaScript by connecting to the RESTful API integrated into Flask.  However, when I make the request, I receive the following error: XMLHttpRequest cannot load http://myApiUrl/login. No 'Access-Control-Allow-Origin' header ...READ MORE

Sep 20, 2022 in Java by Nicholas
• 7,760 points
507 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP