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

492
Views
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 answers
Answer question

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 Report
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!