Getting Error : Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://localhost:3000') does not match the recipient window's origin ('http://localhost:3030')
Hi, I am getting error when trying to submit login
Ubuntu 18.04 Rocket chat server running on http://localhost:3000 This application running on http://localhost:3030 Error in console : Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://localhost:3000') does not match the recipient window's origin ('http://localhost:3030')
Same problem here. Are we misunderstanding something, it is a ssl problem?
I just got this running fine with following configs on rocket.chat

are you guys trying with same configs?
Same problem for me, i just need understand whats is Iframe Url and API URL, because i have my application and rocketchat in different domains.
I am have the same problem. Did you find a solution?
- You log in to the rocket chat programmatically and get a token
- you create on a certain URL (Iframe URL) the output of js code performing authorization in the window where it is displayed and the received token is already present in it
- the web interface only works through the receipt of this code, the web interface always requests a token code for this url
- you cannot log in directly through the web interface
yes? this is not very nice because the chat is used in different ways at the same time :)
And to be able to get a token from the current session it is necessary that the domains of the site and chat were the same. No other options?
Same problem here, I need acces from https://localhost to development tests. I Try change cors permssion and nothing happens..
Any news about this? I facing the same issues!
Honestly, I don't get how I should identify the user when the iframe calls sso route. I mean it ´is an iframe - I cannot access any cookie which I set before on the parent host.
From My understanding, they want you to drop the ifrmye in the html:
<iframe width="100%;" height="100%" src="https://my.rocketchat.com/channel/general?layout=embedded" frameborder="0"></iframe> Then the iframe will try to call the sso route if this is not working it will try to call the login route.
So the frontend has to insert the script tag or to save the token somehow. But this nowhere shown. So I am kinda confused. I appreciate the example but it seems that it needs a little more explanation.
@giterium did you figure out a way to request it from a different domain?
I fixed the issue by navigating to "General" tab under the "Administration" settings and unchecked "Restrict access inside any Iframe"
<script>
console.log('initializing the chat box');
let host = 'https://rocket.rdicorp.com';
fetch(host + '/api/v1/login', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
body: 'user=' + encodeURIComponent('username_goes_here') + '&password=' + encodeURIComponent('password_goes_here')
}).then((response) => response.json())
.then((respose) => {
console.log('chat logged in', respose, respose.data.authToken);
let container = document.getElementById('chat-box-holder');
if (respose.status == 'success') {
var frame = document.createElement('iframe');
frame.src = host +'/channel/general/?layout=embedded';
frame.title = 'Chat box';
frame.scrolling = 'no';
frame.frameBorder = '0';
container.appendChild(frame);
frame.contentWindow.postMessage({
event: 'login-with-token',
loginToken: respose.data.authToken
}, host);
}
});
</script>