Getting error has been blocked by CORS policy when making api call

iRohitBhatia

I am getting the following error when I am trying to make an api call to kickstarter Staff pick json endpoint

This is what the error exactly looks like

localhost/:1 Access to XMLHttpRequest at 'https://www.kickstarter.com/discover/recommended?format=json' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I have previously encountered this error but that was when I was trying to make a local API call.

I known I can enable cors on my browser which might possibly fix the error but I am trying to avoid it.

Any ideas or fixes?

I am using axios for making api calls

axios.get("https://www.kickstarter.com/discover/recommended?format=json").then(response => {

[Update:] Can someone also help me in figuring out how we can use it with Promise.

 let Base_url = axios.get(base_url)
  let StaffPick = axios.get(staffPick)


   return Promise.all(Base_url, StaffPick).then(response => {

Where staff pick is https://www.kickstarter.com/discover/recommended?format=json and base_url is: http://coincap.io/map

SakoBu

Try it like this and it should work:

fetch(
  'https://cors-anywhere.herokuapp.com/https://www.kickstarter.com/discover/recommended?format=json')
  .then(response => response.json())
  .then(data => console.log(data));

Or the equivalent with axios...

Here is live demo on code sandbox: https://codesandbox.io/s/ox7wz9ny15

Instead of writing our own proxy server we're using this one: https://github.com/Rob--W/cors-anywhere

Note: if you want to use this in production I would recommend writing your own proxy server... More info on CORS: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Stackexchange REST API has been blocked by CORS policy

From Dev

Problem with Post API: "has been blocked by CORS policy...."

From Dev

still get error on has been blocked by CORS policy

From Dev

Error: Access to XMLHttpRequest has been blocked by CORS policy Flask API + NodeJs

From Dev

I'm getting "blocked by CORS policy" when I try to call Instagram API using Axios

From Dev

Access to XMLHttpRequest has been blocked by CORS policy

From Dev

CORS Policy has been blocked my subdomain

From Dev

file uploading has been blocked by CORS policy

From Dev

URL has been blocked by CORS policy

From Dev

Why do im receving the Cors Error :...has been blocked by CORS policy

From Java

Spring Security CORS: Origin has been blocked by CORS Policy

From Dev

AWS API call is being blocked by the CORS policy

From Dev

Error .net 6 cors policy "has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."

From Dev

Access to fetch at 'API URL' from origin 'LOCALHOST' has been blocked by CORS policy .net 6

From Dev

Access to fetch at 'https://api.kendozone.com/auth/login' from origin[...] has been blocked by CORS policy

From Dev

Access to XMLHttpRequest at 'http://localhost/api from origin 'http://localhost:8000' has been blocked by CORS policy

From Java

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

From Dev

Sending request from React to FastAPI causes "origin http://localhost:5173 has been blocked by CORS policy" error

From Dev

"Redirect has been blocked by CORS policy" Vue Axios

From Javascript

Access to Script at ' from origin 'null' has been blocked by CORS policy

From Dev

Django Vue Js Axios has been blocked by CORS policy

From Dev

origin 'http://127.0.0.1:5174' has been blocked by CORS policy:

From Dev

How to fix XMLHttpRequest has been blocked by CORS policy

From Dev

How to solve Access to XMLHttpRequest has been blocked by CORS policy?

From Dev

"...has been blocked by CORS policy: No 'Access-Control-Allow-Origin' "

From Dev

origin has been blocked by CORS policy Spring boot and React

From Dev

Access to remote URL has been blocked by CORS policy

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 Dev

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

Related Related

  1. 1

    Stackexchange REST API has been blocked by CORS policy

  2. 2

    Problem with Post API: "has been blocked by CORS policy...."

  3. 3

    still get error on has been blocked by CORS policy

  4. 4

    Error: Access to XMLHttpRequest has been blocked by CORS policy Flask API + NodeJs

  5. 5

    I'm getting "blocked by CORS policy" when I try to call Instagram API using Axios

  6. 6

    Access to XMLHttpRequest has been blocked by CORS policy

  7. 7

    CORS Policy has been blocked my subdomain

  8. 8

    file uploading has been blocked by CORS policy

  9. 9

    URL has been blocked by CORS policy

  10. 10

    Why do im receving the Cors Error :...has been blocked by CORS policy

  11. 11

    Spring Security CORS: Origin has been blocked by CORS Policy

  12. 12

    AWS API call is being blocked by the CORS policy

  13. 13

    Error .net 6 cors policy "has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."

  14. 14

    Access to fetch at 'API URL' from origin 'LOCALHOST' has been blocked by CORS policy .net 6

  15. 15

    Access to fetch at 'https://api.kendozone.com/auth/login' from origin[...] has been blocked by CORS policy

  16. 16

    Access to XMLHttpRequest at 'http://localhost/api from origin 'http://localhost:8000' has been blocked by CORS policy

  17. 17

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

  18. 18

    Sending request from React to FastAPI causes "origin http://localhost:5173 has been blocked by CORS policy" error

  19. 19

    "Redirect has been blocked by CORS policy" Vue Axios

  20. 20

    Access to Script at ' from origin 'null' has been blocked by CORS policy

  21. 21

    Django Vue Js Axios has been blocked by CORS policy

  22. 22

    origin 'http://127.0.0.1:5174' has been blocked by CORS policy:

  23. 23

    How to fix XMLHttpRequest has been blocked by CORS policy

  24. 24

    How to solve Access to XMLHttpRequest has been blocked by CORS policy?

  25. 25

    "...has been blocked by CORS policy: No 'Access-Control-Allow-Origin' "

  26. 26

    origin has been blocked by CORS policy Spring boot and React

  27. 27

    Access to remote URL has been blocked by CORS policy

  28. 28

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

  29. 29

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

HotTag

Archive