1

I am trying to do a search profile of a customer from my CRM using AWS CustomerProfilesClient SDK's searchProfile API.

Though I am passing Access-Control-Allow-Origin header along with the body in the api request, it is giving me an error saying that Access to fetch at 'https://XXXXXXXXXXXX-connect-profiles/profiles/search' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Below is the snippet of the code where I am trying to do the get request. Am I missing something here ?

 const input = { 
    "DomainName": 'gettingreadywithconnect-profiles',
    "KeyName": "_phone",
    "Values": ["+1 xxx xxx xxxx"],
  };

  useEffect(() => {
    console.log("Profiles initliazed...", profiles)
    const command =  client.searchProfiles(input, { "Access-Control-Allow-Origin": "*"});
    console.log("response", command)
  }, [initializeProfiles])

Tried passing access control header with api request.

1 Answers1

1

I‘m not sure tbh, but you probably need to add your origin url to the your Connect instances approved origins:

https://docs.aws.amazon.com/connect/latest/adminguide/app-integration.html

lkrimphove
  • 229
  • 2
  • 7