N
N
Nikita2019-08-31 12:36:14
AJAX
Nikita, 2019-08-31 12:36:14

How to resolve Access-Control-Allow-Origin when requested via axios?

I make a request to the site through axios:

export const converterAPI = {
  getData() {
    return axios.get('https://currate.ru/api/?get=rates&pairs=USDRUB,EURRUB,EURGBP&key=KEY')
    .then(response => response.data) 
  }
}

It gives the following error: Access to XMLHttpRequest at ' https://currate.ru/api ' from origin ' localhost:3000 ' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource .
One solution is to add Access-Control-Allow-Methods: *only it does not help, please tell me how to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2019-08-31
@SonyFan23

The Access-Control-Allow-Origin header must be present in the currate.ru site response.
Without such a header, you can only make requests via AJAX from the pages of the currate.ru site.
The solution is to make a request through the backend of your site.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question