open-cti-demo-adapter icon indicating copy to clipboard operation
open-cti-demo-adapter copied to clipboard

Cross origin frame issue

Open alexispissinier opened this issue 8 years ago • 33 comments
trafficstars

Hello guys

Im trying to install the Open cti package and to make it works for demo before playing with it and customize it, but the softphone does not appear why clicking on the Phone tab in the console.

Here is the issue I face Blocked a frame with origin "https://MYDOMAIN.my.salesforce.com" from accessing a cross-origin frame. No 'Access-Control-Allow-Origin' header is present on the requested resource.

Any clue on how this can be solved? Im working on a developer edition for now

Thanks a lot!

alexispissinier avatar May 04 '17 09:05 alexispissinier

Hi, Can you please change the CTI Adapter URL in the Call Center to an absolute url, from /apex/demoAdapterPage to something like https://MYDOMAIN.my.salesforce.com/apex/demoAdapterPage ?

Then try again

dlouvton avatar May 05 '17 05:05 dlouvton

Hi David and thanks for your answer I had setup the url adapter url correctly and still getting that issue. Not sure for where it comes from Best Regards

alexispissinier avatar May 10 '17 08:05 alexispissinier

What is the error you're getting?

dlouvton avatar May 12 '17 16:05 dlouvton

Hi David,

I'm getting the same error. When accessing any page from the Service Cloud Console I can see this error:

iframeinterface.js:1 Uncaught DOMException: Blocked a frame with origin "https://.my.salesforce.com" from accessing a cross-origin frame. at Object.handleOnload (https://.my.salesforce.com/support/console/xdomain/30.0/iframeinterface.js:1:356) at window.onload (https://.my.salesforce.com/support/console/xdomain/30.0/crossDomainProxy.html:4:89)

And when I try to make a call (I have already set up Twilio for that) I get this error on the Softphone page when it's dialing: Uncaught DataCloneError: Failed to execute 'postMessage' on 'Window': [object Object] could not be cloned. throws at https://--c.eu11.visual.force.com/support/api/38.0/lightning/opencti.js:499:13

I have added those URLS to the CORS settings but unfortunately it doesn't make any difference.

Could you please give some advice ? :)

Thanks, Manuel

tejeirodelrio avatar Jun 09 '17 08:06 tejeirodelrio

what is the adapter url in the call center settings? is it relative or absolute? are you using a dev org with a namespace or an enterprise edition org? In most cases, if your My Domain is say, 'manuel', the adapter URL in the call center settings needs to be https://manuel.my.salesforce.com/apex/demoAdapterPage

hope that helps!

David

dlouvton avatar Jun 12 '17 22:06 dlouvton

Hi David,

My URL in the call center settings is absolute (https://xxx-dev-ed.my.salesforce.com/apex/demoAdapterPage). I'm using a dev org without namespace.

What I can see in the console log is as follows: Uncaught DOMException: Blocked a frame with origin "https://xxx-dev-ed.my.salesforce.com" from accessing a cross-origin frame. at Object.handleOnload (https://xxx-dev-ed.my.salesforce.com/support/console/xdomain/30.0/iframeinterface.js:1:356) at window.onload (https://xxx-dev-ed.my.salesforce.com/support/console/xdomain/30.0/crossDomainProxy.html:4:89)

I created a Lightning console app for testing this out. Do you happen to know what I missed out? :)

Regards, Manuel

tejeirodelrio avatar Jun 13 '17 09:06 tejeirodelrio

hmm... it looks ok so i'm not sure what went wrong. Can you try with an enterprise edition org? (you can sign up a free trial one if you don't have one). If that doesn't work, maybe you could open a case with salesforce support.

dlouvton avatar Jun 13 '17 16:06 dlouvton

Hi, David The same issue - http://take.ms/6bK8E But Phone tab is working (i can login and use CTI) P.S. Org was created day ago

adashko avatar Jun 20 '17 23:06 adashko

Hi, Similar issue when I try to do sforce.opencti.isSoftphonePanelVisible({callback: callback}); or any other CT methods from this doc Link

from any of my VFPage added in service console I get this error .. I tried setting the same URL inside open_cti.min.js It doesn't work still.. Any help on how to open soft phone on from a custom VFPage added in Service console will be really help full. Thanks in Advance. :) screen shot 2017-07-31 at 5 37 33 pm

gs-akhan avatar Jul 31 '17 12:07 gs-akhan

Was anyone to resolve the issue ? I'm trying to simulate an incoming call to open a matching contact, but the CTI component goes blank with DOMExceptions in the browser console. Any help appreciated !

Just to be clear, same issue as @tejeirodelrio in a developer org.

nagensahu avatar Aug 10 '17 19:08 nagensahu

Any updates? Is an enterprise edition org required instead?

Update:I still have the issue, but it seems that the phone is working. So maybe we can simply ignore this issue.

tylerlong avatar Aug 17 '17 15:08 tylerlong

Hey guys,

I have been having a similar problem while developing a package using the Salesforce Open CTI extension for a SFDC Telephony Integration project in my company. It seems that after an update calling any code in sforce.opencti.* that is relying on server communication, as for example sforce.opencti.screenPop is failing because of iframe to parent window communication (postMessage).

I could not get sforce.opencti.screenPop working inside AURA, but a small workaround helped me fixing the problem: In the callback (here it is 'then') that is creating the lightning out adapter

$Lightning.use("softphoneOut", function() {
    $Lightning.createComponent(
       "softphone", 
        {},
        "lightning",
        then
    )
});

Just add an alias to the sforce functions:

window.$Force = sforce;

Then inside of AURA you can use: $Force.opencti.screenPop which works without any problems.

A full example could be:

$Lightning.use("softphoneOut", function() {
    $Lightning.createComponent(
       "softphone", 
        {},
        "lightning",
        function() {
            window.$Force = sforce;
        }
    )
});

...

$Force.opencti.screenPop({
    type: $Force.opencti.SCREENPOP_TYPE.SOBJECT,
    params: {
        recordId: recordId
    }
});

I hope this helps!

espspinix avatar Sep 04 '17 10:09 espspinix

@espspinix Thanks a lot !! It works. Could you help me understand how it works ?

nagensahu avatar Oct 13 '17 13:10 nagensahu

@espspinix do you mind creating a pull request with these changes so others can enjoy it?

thanks, David

dlouvton avatar Oct 13 '17 16:10 dlouvton

I was stuck on this two months ago. I did lots of investigation and it turned out it's pretty easy to start from scratch (without this library). Here is a 10-minutes demo for you to integrate RingCentral into Salesforce: https://github.com/ringcentral/ringcentral-web-widget/issues/7

The solution takes RingCentral as example, but the method should apply to other vendors.

tylerlong avatar Oct 18 '17 03:10 tylerlong

Any update on this? I tested in developer edition, the console page is redirect me to the demonAdpaterPage to sign in. Given the sfdcIframeOrgin is in *.lightning.force.com instead of *.visual.force.com, it always fail to execute 'postMessage" on "DOMwindow": The target origin provided ('<URL>'< does not match the recipient window's origin ('<URL>'). I tried methods mentioned above, yet did not work for me.

kenke avatar Jul 17 '18 00:07 kenke

Im getting this error....

Refused to execute JavaScript URL because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-57d8d4d6-e70b-d93b-10de-0da8b6751459' chrome-extension: 'unsafe-inline' 'unsafe-eval' https://sfdc.azureedge.net *.na57.visual.force.com 'unsafe-eval' https://ssl.gstatic.com/accessibility/". Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list.

Any ideas?

caseyboyd avatar Aug 20 '18 16:08 caseyboyd

HI,

Keep getting this error, when click on phone.

SecurityError: Blocked a frame with origin "https://-----.my.salesforce.com" from accessing a frame with origin "https://-----.lightning.force.com". Protocols, domains, and ports must match. handleOnload onload I tried below to resolve this but it doesn't go :

  1. Whiltelisting iframe URL on CORS
  2. adding domain name in adapter URL for demoAdapterPage.
  3. Disabling cross window navigation in chrome.
  4. Updating code as per espspinix comment above.

I am testing this on Safari and Chrome, but it seems not working for me. Don't want to use any other vendors API but wanted to use what all demo adapter provides but no luck yet :(

Thanks in advance.

buildup1 avatar Sep 25 '18 17:09 buildup1

Hi,

any generic solution to this issue? i have tried CORS settings and what @espspinix explained but no luck.

@dlouvton : is there any update with a working fix ?

Thank you

Nkunzis avatar Mar 04 '19 21:03 Nkunzis

Im getting this error....

Refused to execute JavaScript URL because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-57d8d4d6-e70b-d93b-10de-0da8b6751459' chrome-extension: 'unsafe-inline' 'unsafe-eval' https://sfdc.azureedge.net *.na57.visual.force.com 'unsafe-eval' https://ssl.gstatic.com/accessibility/". Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list.

Any ideas?

Hey, did you find any solutions to this? This happens on list view of contact: Refused to run the JavaScript URL because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-b3c546f8-ab5b-d9c9-98bf-1783b8041fa1' chrome-extension: 'unsafe-eval' https://sfdc.azureedge.net *.visualforce.com https://ssl.gstatic.com/accessibility/ https://static.lightning.force.com". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.

nikhilcloudroute avatar May 21 '19 11:05 nikhilcloudroute

When I deployed the code using SFDX I had the same issue "Uncaught DataCloneError: Failed to execute 'postMessage' on 'Window'", but when I installed the package it worked. I couldn't figure it out the reason. I used the same settings in both cases. Any suggestions?

jessizanelato avatar Jun 03 '19 16:06 jessizanelato

Hey, did you find any solutions to this? This happens on list view of contact: Refused to run the JavaScript URL because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-b3c546f8-ab5b-d9c9-98bf-1783b8041fa1' chrome-extension: 'unsafe-eval' https://sfdc.azureedge.net *.visualforce.com https://ssl.gstatic.com/accessibility/ https://static.lightning.force.com". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.

nikhilcloudroute avatar Jun 20 '19 10:06 nikhilcloudroute

I'm getting a much basic error that says

Cannot read property 'opencti' of undefined

I have included the necessary resources:

<script type="text/javascript" src="/support/api/38.0/lightning/opencti.js"></script>
<script src="/support/api/40.0/interaction.js" type="text/javascript"></script>

I am building a very basic implementation, but cannot seem to get it to get the softphone to work as expected. I can place a call, but the component fails.

Can anyone here tell me what I seem to be missing here?

ManjunathGithubAcc avatar Jun 20 '20 12:06 ManjunathGithubAcc

Can you make sure the script is loaded. This error comes when the js is not loaded.

May be put a time delay on load the cti method just to test.

nikhilcloudroute avatar Jun 22 '20 04:06 nikhilcloudroute

Hi @nikhilcloudroute I figured out the issue. I was loading the resource via a relative URL, turns out that I had to use the absolute URL. It is working now.

ManjunathGithubAcc avatar Jun 22 '20 04:06 ManjunathGithubAcc

Great!

nikhilcloudroute avatar Jun 22 '20 04:06 nikhilcloudroute

My problem was that I had amazonconnect appended to my salesforce url in my allowed URLs in AWS. Maybe this will help someone in the future.

nicholasbulka avatar Sep 27 '20 00:09 nicholasbulka

I have the same problem. Is there any update with fix ?

ilkokrastev avatar Jan 25 '21 22:01 ilkokrastev

Hi @nikhilcloudroute I figured out the issue. I was loading the resource via a relative URL, turns out that I had to use the absolute URL. It is working now.

Could you please share the path that you are referring to.

Thanks.

naveenudatha avatar Jun 17 '21 14:06 naveenudatha

@nikhilcloudroute @ManjunathGithubAcc can you guys please post here the solution? Thanks

vlad-pustiu avatar Sep 03 '21 06:09 vlad-pustiu