Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

418
Views
.htaccess Access-Control-Allow-Origin not allowing specific domains

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>
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!