Is it possible to resolve the No 'Access-Control-Allow-Origin' error on the front end?

Asked

Viewed 122 times

0

Personal need to consume a third party API with Javascript, I do not have access to release Cors in the API.. and this error is appearing as I can solve ? I have the following request using Axios: Obs: when I make the request in Postman it’s working.

axios({
  method: 'POST',
  url: url,
  data: {},
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Accept': 'application/json'
  }
}).then(res => {
  console.log(res);
}).catch(err => {
  console.log(err);
})

Thank you!

  • There is no solution on the front end. You will need to build a proxy in your back end and request through it.

  • Or use a public proxy as https://corsproxy.github.io/

  • How does this corsorigin.me ? just put before the url ? I tried here didn’t work out.. vlw..

  • As it says on the site itself, there is no way to guarantee the availability of the service. So it is better to have your own proxy. This answer has a simple example in php.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.