Error Vue and Axios CORS No header "Access-Control-Allow-Origin" is present on the requested resource

I am currently getting the above error, I am using Axios to make the GET request an external API. Having read the Mozilla docs, doing a lot of research and trying to use different options, I still feel no better.

I canceled the code to the basics:

axios.get('URL.com', {
        headers: {
          Access-Control-Allow-Origin: *
        },
        auth: {
          username: 'username',
          password: 'password'
        },
      })
      .then(function (response) {
        console.log(response);
      })
      .catch(function (error) {
        console.log(error);
      });

Do I need to add anything else to the headers?

Everything works through Postman, so as soon as I can convey the CORS problem, everything will work.

+4
source share
1 answer
baseURL: 'https://www.yourserver.com.br',
timeout: 10000,
withCredentials: false
0
source

Source: https://habr.com/ru/post/1667427/


All Articles