Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

419
Vistas
.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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda