1$origin = $_SERVER['HTTP_ORIGIN'];
2$allowed_domains = [
3 'http://mysite1.com',
4 'https://www.mysite2.com',
5 'http://www.mysite2.com',
6];
7
8if (in_array($origin, $allowed_domains)) {
9 header('Access-Control-Allow-Origin: ' . $origin);
10}
11