Cross-Origin Resource Sharing (CORS) is a security feature implemented by web browsers to control how web pages in one domain can request and interact with resources hosted on another domain. This is done to prevent malicious websites from making unauthorized requests to a different domain on behalf of the user.
Example
Let's consider two servers: https://raided.eu (the main server) and https://assets.raided.eu (a server serving static assets). Suppose you have a web page hosted on https://raided.eu that needs to fetch some images from https://assets.raided.eu. Without proper CORS configuration, the server would block this request.
To enable CORS, the server at https://assets.raided.eu must include the appropriate CORS headers in its responses. These headers specify which domains are allowed to make requests and which HTTP methods are permitted.
Tutorial
To add a CORS header to your website (with an Apache server), follow the steps below:
1. First, open or create an .htaccess file located in the root directory of your server.