JSByte: The Access-Control-Allow-Origin Header Explained
Often times when calling an API, you may see an error in your console - `Access to fetch at http://somesite.com from origin http://yoursite.com has been blocked by CORS policy: The Access-Control-Allow-Origin header has a value that is not equal to the supplied origin`. This post talks about why this error occurs and how it can be fixed.
`Access-Control-Allow-Origin` is a Cross Origin Resource Sharing (CORS) header. CORS is a mechanism for browsers to let a site running at origin A to request resources from origin B. In order to allow origin A to access your resources, origin B will need to let the browser know that it is okay for certain origins to receive resources from it. This is where `Access-Control-Allow-Origin` comes into action. To let origin A access resources, origin B will need to set this header as part of its response.
Read the full post: https://www.freecodecamp.org/news/access-control-allow-origin-header-explained/