CORS policy error while calling remote URL in Angular

ketan

Try to call remote API Url but, getting Access-Control-Allow-Origin error. I tried many things like following but, nothing works.

proxy.conf.js

const PROXY_CONFIG = [
  {
    context: [
      "/api/planets"
    ],
    target: "https://swapi.co",
    secure: false,
    changeOrigin: true,
    logLevel: "debug",
    bypass: function (req, res, proxyOptions) {
      req.headers["Access-Control-Allow-Origin"] = "*";
      req.headers["X-Forwarded-Host"] = "localhost:8090";
      req.headers["X-Forwarded-For"] = "localhost";
      req.headers["X-Forwarded-Port"] = "8090";
      req.headers["X-Forwarded-Proto"] = "http";
    }
  }
];

module.exports = PROXY_CONFIG;

Running with ng serve --port 8090 --proxy-config proxy.conf.js

Can't make any changes in server side because I am using third party API.

enter image description here

Shashank Vivek

Try adding plugin like https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf?hl=en in your chrome browser.

Since you cant change the server side config, so this plugin can do the trick. The browser by default blocks CORS

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From

Blocked by CORS policy error when calling to mongo/golang db with angular web app

From Dev

Access to remote URL has been blocked by CORS policy

From Dev

Angular/Ionic CORS Policy

From Dev

CORS error while consuming calling REST API with React

From Dev

Blocked By CORS Policy Angular and Slim

From Dev

CORS policy blocked on Angular / NGINX

From Dev

Angular + Spring. CORS policy

From Dev

CORS error when calling Firebase Callable Functions from Angular?

From Dev

Error: Access to XMLHttpRequest at https://storage.googleapis.com/url from origin has been blocked by CORS policy. In angular when using gcp SignedURl

From Java

CORS error while connecting Angular with spring boot for JWT

From Dev

URL has been blocked by CORS policy

From Dev

Getting Around "blocked by CORS policy" Error in Angular App Running Local Instance of API

From Java

Angular 6 + Spring Boot: Error: "from origin 'http://localhost:4200' has been blocked by CORS policy"

From Dev

Getting an error "blocked by CORS policy" only for "https://localhost:44361/connect/token" in Angular 7 web app

From Dev

blocked by CORS policy in ionic-5 angular

From Dev

Angular: How can be stop "CORS policy" issuse?

From Dev

Error while calling External REST URL from netsuite using token

From Dev

Error while calling spring controller action through URL posting

From Dev

Deployment error while referring deployment yaml directly from remote URL

From Dev

React Axios Dispatching CORS policy error

From Dev

cors-error although endpoint exists in policy

From Dev

React - fetching from API, CORS policy error

From Dev

CORS policy error in only one action of API

From Dev

Any idea why have this CORS error policy?

From Dev

Nest.js/Angular - CORS Enabled but still getting a CORS error while making requests

From Dev

Error while calling a function

From Dev

Spring/Angular CORS issue while CORS is enabled

From Dev

Error with CORS when calling local c# api from an Angular project

From Dev

Getting error while setting the content-security-policy using Angular4

Related Related

  1. 1

    Blocked by CORS policy error when calling to mongo/golang db with angular web app

  2. 2

    Access to remote URL has been blocked by CORS policy

  3. 3

    Angular/Ionic CORS Policy

  4. 4

    CORS error while consuming calling REST API with React

  5. 5

    Blocked By CORS Policy Angular and Slim

  6. 6

    CORS policy blocked on Angular / NGINX

  7. 7

    Angular + Spring. CORS policy

  8. 8

    CORS error when calling Firebase Callable Functions from Angular?

  9. 9

    Error: Access to XMLHttpRequest at https://storage.googleapis.com/url from origin has been blocked by CORS policy. In angular when using gcp SignedURl

  10. 10

    CORS error while connecting Angular with spring boot for JWT

  11. 11

    URL has been blocked by CORS policy

  12. 12

    Getting Around "blocked by CORS policy" Error in Angular App Running Local Instance of API

  13. 13

    Angular 6 + Spring Boot: Error: "from origin 'http://localhost:4200' has been blocked by CORS policy"

  14. 14

    Getting an error "blocked by CORS policy" only for "https://localhost:44361/connect/token" in Angular 7 web app

  15. 15

    blocked by CORS policy in ionic-5 angular

  16. 16

    Angular: How can be stop "CORS policy" issuse?

  17. 17

    Error while calling External REST URL from netsuite using token

  18. 18

    Error while calling spring controller action through URL posting

  19. 19

    Deployment error while referring deployment yaml directly from remote URL

  20. 20

    React Axios Dispatching CORS policy error

  21. 21

    cors-error although endpoint exists in policy

  22. 22

    React - fetching from API, CORS policy error

  23. 23

    CORS policy error in only one action of API

  24. 24

    Any idea why have this CORS error policy?

  25. 25

    Nest.js/Angular - CORS Enabled but still getting a CORS error while making requests

  26. 26

    Error while calling a function

  27. 27

    Spring/Angular CORS issue while CORS is enabled

  28. 28

    Error with CORS when calling local c# api from an Angular project

  29. 29

    Getting error while setting the content-security-policy using Angular4

HotTag

Archive