Skip to main content

Hello,

 

I'm trying to making callout to the third party system but facing CORS error. even i have added the domain under setup > CORS and Trusted CSP sites as well... still throwing the error. Can anyone help me with this please...

 

Error::

Access to fetch at 'thirdpartyURL'  from origin 'salesforceURL'  has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'thirdpartyURL' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

 

fetch(url, {

            method: 'POST',

            body: formData,

            headers:{ 

                "Accept":"application/json",

                "Authorization": "Bearer " + accessToken,

            }

        })

        .then(response => {

         })

        .catch(error => {

        })

CORS error callout from LWC

 

 

#Salesforce Developer

3 respuestas
  1. 13 mar 2024, 6:18

    Hi @Abhijeet Soni,

     

    Thanks for the quick response. I did tried with no CORS as well but it doesn't helps. The exception is handled and no actual response returned from the API. Is there any other approach could help to handle from client side?

    Hi , Thanks for the quick response. I did tried with no CORS as well but it doesn't helps. The exception is handled and no actual response returned from the API.