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?
Привет, я смог решить эту проблему с помощью этого кода
<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>
Похоже, вы неправильно указываете источник. Попробуйте вместо этого:
Заголовок set Access-Control-Allow-Origin "https: //video.xyz.example"
Если вы пытаетесь найти решение проблем межсайтового происхождения на всех поддоменах вашего домена, здесь есть гораздо более надежный ответ: