From my localhost, I tried to access a file called fonts.css, which imports fonts.
When I add the snippet to my css, I get the following error:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
CSS file:
@import "http://drupal-site.lndo.site:8000/fonts.css?timestamp=22222231";
As a workaround, I tried the following within the .htaccess:
SetEnvIf Origin "^http(s)?://(.+\.)?(localhost:4200|domain1\.com:5100|domain2\.com)$" origin_is=$0
Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is
When I attempt the same request, I still get the same CORS error.
How can I whitelist domains using if statements within the .htaccess file?
I tried this:
<IfModule mod_headers.c>
<If "req('Host') == 'localhost:4200'">
RedirectMatch (.*) http://www.wooga.com$1
Header set Access-Control-Allow-Origin localhost:4200
</If>
</IfModule>