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

490
Vistas
Angular : CORS problem when loading external script or ressource

Under my angular App , i'm using renderer2 to load some javascript ressources by injecting them to the head of window

That s working fine but ;

When serving locally , this loading the ressource fails since there is a CORS problem :

Access to XMLHttpRequest at 'https://website/src/style1.css' from origin 'http://192.168.244.128:3001' has been blocked by CORS policy: Request header field x-requested-with is not allowed by Access-Control-Allow-Headers in preflight response.

Note : i'm running my Angular app in my local machine but i'm using some url redirection since it's a vmware virtual machin , that's why my local url is : http://192.168.244.128:3001

I ve tried to use an Angular proxy like this :

proxy.conf.json :

{
  "/*": {
    "target": "https://website/src/style1.css",
    "secure": false,
    "changeOrigin": true,
    "logLevel": "debug"
  }
}

But the problem persists

Suggestions ??

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

target should be a domain server + port but not a direct resource path

"target": "https://{domain}:{port}"

I also advice you to use a url keyword to identify external requests (in my sample below i choose "resources")

For sample if you want to access

https://website/src/style1.css

you have to access it by

localhost:{localport}/resources/src/style1.css or resources/src/style1.css

here a proxy config

{
    "/resources/*": {
      "target": "https://website",
      "secure": false,
      "changeOrigin": true,
      "pathRewrite": {
        "^/resources": ""
      },
      "logLevel": "debug"
    }
  }
about 4 years ago · Juan Pablo Isaza Denunciar
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