5

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?

1
  • A CORS origin requires a valid protocol which you haven't provided. For example, http://video.xyz.example and https://video.xyz.example are two different origins. See answer below serverfault.com/a/923220/202676
    – natbusa
    Nov 29, 2021 at 13:20

4 Answers 4

5

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

4

Hi I was able to solve it using this code

<IfModule mod_headers.c>
   SetEnvIfNoCase Origin "https?://(www\.)?(xyz\.com|video\.xyz\.com)(:\d+)?$" ACAO=$0
   Header set Access-Control-Allow-Origin %{ACAO}e env=ACAO
</IfModule>
1
  • where should i add this? Jan 10, 2023 at 21:00
1

It looks like you may be specifying the origin incorrectly. Try this instead:

Header set Access-Control-Allow-Origin "https://video.xyz.example"

0

Just found this page by searching for my problem. It is also with subdomains, but also with different top level domains.

some-subdomains.GEMINI-next-Generation.House for English content some-subdomains.GEMINI-next-Generation.Haus for German content

So the wildcard would have to be https://*.GEMINI-next-Generation.H*

How to bring this in a header line?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .