CORS error at token endpoint

I have the below code block to call the token endpoint. The endpoint succeeds from Postman with JSON response but from my web application, it fails with CORS error. What could be the reason for this behavior?

const axios = require('axios');
const qs = require('qs');
let data = qs.stringify({
  'grant_type': 'authorization_code',
  'code': 'xxxxxxyyyyybbb,
  'redirect_uri': 'https:myApp/login',
  'client_id': 'com.myclient_id',
  'client_secret': 'myworkingsecret' 
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://appleid.apple.com/auth/token',
  headers: { 
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);

});