Skip to content

InitCCP login iframe not rendering. Error:'frame-ancestors' violation

0

I am trying to invoke initCCP from my node.js front-end using localhost. I have approved access for localhost:3000 in my Connect instance. However the Connect CCP window is getting blocked with the following error - "Refused to frame 'https://<...>.my.connect.aws/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'none'". Any suggestions on which file to fix and any reference code I can use? I am a total neophyte and have built a prototype leveraging freelancers - so any help will be fantastic.

' const ConnectCCP = ({ phoneNum }) => { const ref = useRef(); const [contactId, setContactId] = useState(""); //const [sourcePhone, setSourcePhone] = useState("1" + phoneNum.replace(/\D/g, "")); const [sourcePhone, setSourcePhone] = useState("1208--<....>-); // Phone for testing purposes const [destPhone, setDestPhone] = useState(""); const [contactFlowId, setContactFlowId] = useState("b7f26976-<....>-bf6ea1b19e91"); const [instanceId, setConnectInstanceId] = useState("695227e1--<....>--1fd6f882ea55"); const [queueARN, setQueueArn] = useState("a81629fc-<....>-34c2e2818e39");

const [buttonState, setButtonState] = useState("enabled"); //for testing hard coded destination phone number var testnumber = "<phone-number>"; // for testing only var testing = false; //change this flag if not testing code

useEffect(() => { const update = async () => { if (typeof navigator !== 'undefined') { try { (await import("amazon-connect-streams")); connect.core.initCCP(ref.current, { ccpUrl: "https://<myinstance>.my.connect.aws/connect/ccp-v2", region: "us-east-1", loginPopup: true, // optional, defaults to true loginPopupAutoClose: true, // optional, defaults to true loginOptions: { // optional, if provided opens login in new window autoClose: true, // optional, defaults to false height: 600, // optional, defaults to 578 width: 400, // optional, defaults to 433 top: 0, // optional, defaults to 0 left: 0, // optional, defaults to 0 }, softphone: { // optional, defaults below apply if not provided allowFramedSoftphone: true, // optional, defaults to false disableRingtone: false, // optional, defaults to false // ringtoneUrl: "./ringtone.mp3" // optional, defaults to CCP’s default ringtone if a false value is set }, pageOptions: { // optional enableAudioDeviceSettings: true, // optional, defaults to 'false' enablePhoneTypeSettings: true, // optional, defaults to 'true' }, contactFlowId, ccpAckTimeout: 5000, //optional, defaults to 3000 (ms) ccpSynTimeout: 3000, //optional, defaults to 1000 (ms) ccpLoadTimeout: 10000, //optional, defaults to 5000 (ms) }); global.connect.agent((agent) => { console.log("Agent initialized");

    // Handle agent state changes
    agent.onStateChange((state) => {
      console.log("Agent state changed:", state);
    });




    // Handle agent error
    agent.onError((error) => {
      console.error("Agent error:", error);
    });

    // Handle agent availability
    agent.onRoutableState((routableState) => {
      console.log("Agent routable state:", routableState);
    });
  });
  console.log("initCCP end");
} catch (error) {
  console.error("Error initializing CCP:", error);
}

} } update(); }, [ref]);

const outBoundCall = async () => { setButtonState("callActived"); if (testing) {setDestPhone(testnumber)};

try {
  const { data } = await axios.get(
    `https://<api-url>.us-east-1.amazonaws.com/dev/GetConnectManager?destPhone=%2B${destPhone}&queueARN=${queueARN}&sourcePhone=%2B${sourcePhone}&instanceId=${instanceId}&contactFlowId=${contactFlowId}`
  );
  setContactId(JSON.parse(data.body).ContactId);
  setButtonState("hangUpActived");
} catch (error) {
  console.log("error", error);
}

};

'

asked 2 years ago1.5K views

3 Answers
1

I don't know if you still encounter this issue, but I had to deal with the same problem and this comes up first when you google for an solution, so I will add my solution for others to find:

Despite using the official sample code from the connect-streams repo and adding the url to the approved origins I wasn't able to get my CCP running. Tried it on multiple browsers, s3, localhost, etc. Nothing did work. Then I noticed that the problem is that most modern browser block the CCP for whatever reason. In Firefox you have to turn off the "Enhanced Tracking Protection" (little shield icon next to the url). Then everything works fine. There are probably similiar features in other browsers.

answered 2 years ago

  • Thanks for the Comment that was exactly the problem we had thank you very much

  • I posted my answer below but this solution is still effective on Firefox as of October 2025.

0

I had the similar issue with at v2.19.2 and resolved the problem on Chrome.

Steps

Please try the followings:

  1. Go to chrome://settings/content/all?searchSubpage=aws. Delete all cookies and settings.
  2. Go to chrome://settings/content/all. Search the websites you are embedding CCP, like example.com. Delete all cookies and settings of it.
  3. Go to chrome://settings/content/storageAccess. Make sure "Sites can ask to use information they've saved about you" is checked and no not-allowed site is on the blocked list, especially awsapps.com and connect.aws
  4. Go to https://your-instance-name.my.connect.aws/ccp-v2/ and login to CCP. Allow any permissions asked.
  5. Go to your website that embeds CCP(Amazon Connect Streams). Allow any permissions asked.

Do not forget to add your origin to the allowed list of your Connect instance.

Localhost does not work

As of October 2025, the origin http://localhost does not work either because the HTTPS protocol is required or it is now on the permanent blacklist in the Streams ecosystem.

The http://localhost app throws the X-Frame-Options: sameorigin error even if it is an allowed origin.

You can run the localhost as an Agent Workspace 3rd party application/service but not as a Streams app.

Resources

(Actually, the source the AI agent shared was helpful.)

answered a year ago

-1

The issue you're experiencing with the Connect CCP window being blocked is likely due to Content Security Policy (CSP) restrictions. To resolve this, you need to properly configure the X-Frame-Options header and ensure that your domain is added to the approved origins list in your Amazon Connect instance.

Here are some steps to address the problem:

  1. Update your Express.js application to set the appropriate X-Frame-Options header. Instead of using a dynamic value, set it to a safe, static value. For example:

res.setHeader("X-Frame-Options", "SAMEORIGIN");

This will allow your page to be framed by pages from the same origin.

  1. Ensure that you've correctly added your domain (localhost:3000 in this case) to the Approved origin list in your Amazon Connect instance. To do this:
  • Log in to the AWS Management Console
  • Navigate to the Amazon Connect console
  • Select your instance
  • Go to "Application integration"
  • Choose "Add origin"
  • Enter "http://localhost:3000" (assuming you're using http for local development)
  1. In your initCCP function, make sure you're using the correct URL format. Update the ccpUrl to use '/ccp-v2' instead of '/connect/ccp-v2':

ccpUrl: "https://<your-instance-name>.my.connect.aws/ccp-v2"

  1. If you're using SAML 2.0 for identity management, ensure that the SAML URL destination is updated to "/connect/ccp-v2".

  2. Review your network settings and consider using Option 1: Replace Amazon EC2 and CloudFront IP range requirements with a domain allowlist.

  3. If you're still encountering issues, try clearing your browser cache and cookies, especially any entries associated with awsapps.com or connect.aws.

By implementing these changes, you should be able to resolve the Content Security Policy violation and successfully render the Connect CCP iframe in your application.

Sources
Allow the Amazon Connect Contact Control Panel (CCP) to access cookies - Amazon Connect
Improper restriction of rendered UI layers or frames | Amazon CodeGuru, Detector Library
Upgrade your Contact Control Panel (CCP) when using the Amazon Connect Streams API - Amazon Connect

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.