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

289
Views
CORS error when trying to call get API in Angular

I am trying to get HTML data from any website using get API.

I have this URL: https://www.linkedin.com/

I am trying to get HTML page as text from this URL.

What I tried:

  getData() {
    const api = "https://www.linkedin.com/";
    return this.httpClient.get(api, { responseType: "text" });
  }

 ngOnInit(): void {
    this.getData().subscribe((value) => {
      console.log(value);
    });
  }

I got this error:

Access to XMLHttpRequest at 'https://www.linkedin.com/' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

What did I miss?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to have proxy requests to enable CORS in your angular application. For doing this, simply create a proxy.config.json file and enter something like this.

{
 "/api": {
 "target": "http://localhost:5000",
 "secure": false
 }
}

You then need to inform angular about this configuration. You can do this by adding a proxyConfig option inside your angular.json file.

"architect": {
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "application-name:build",
"proxyConfig": "src/proxy.config.json"
},
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!