CORS error

My application is on Cloudflare but deployed on Heroku, I am trying to access a 3rd party API from Nextjs frontend but when using axios to post to that API I get the error below, is there a way to fix it?

Access to XMLHttpRequest at ‘https:APIURL’ from origin ‘https://myappURL’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

These are my7 codes where I use axios to hit the API route

axios.post('https:APIURL', xmldata, {'Content-Type':'application/xml'}).then((response) =>{
    const parser = new DOMParser();
    const xmlDoc = parser.parseFromString(response.data,"application/xml");
    const token = xmlDoc.getElementsByTagName("TransToken")[0].childNodes[0].nodeValue;
    setLoading(false)
    return router.push(`https://APIURL?ID=${token}`);
   }).catch((error)=>{
       console.log(error)
   })

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.