Apache2 .htaccess – How to Enable Cross-Origin for Subdomain

.htaccessApache2

I have 2 subdomains, av.xyz.example and video.xyz.example. I want to enable CORS for video.xyz.example on av.xyz.example.

I have added the following code snippet in the apache configuration file of av.xyz.com

Header set Access-Control-Allow-Origin "video.xyz.example"`

But I get the following error

The 'Access-Control-Allow-Origin' header contains the invalid value 'video.xyz.example'. Origin 'https://video.xyz.example' is therefore not allowed access.`

I tried doing it with * and still got an error that it is not permissible for a wildcard, tried doing it using – ^(.*\.xyz\.example)$ and still got the error, invalid value.

What should be the correct value in my scenario?

Best Answer

If you're trying to find a solution to cross-site origin problems on all subdomains for your domain, there's a much more robust answer here:

https://stackoverflow.com/a/39668584/1402498