【发布时间】:2018-12-02 04:18:47
【问题描述】:
我的Rocket chat 托管在https://chat.mydomain.com
我的网络应用(iframe 所在的位置)托管在 https://app.mydomain.com
我已经能够在背面很好地注册用户,在他们登录时返回一个 authToken。当我尝试从我的 ReactJS 应用程序中将 authLogin 发布回 iframe 时...
<iframe src="https://chat.mydomain.com/?layout=embedded" onLoad={() => this.login()} />
...
onLoad(){
window.parent.postMessage({
event: 'login-with-token',
loginToken: authToken
}, 'https://chat.mydomain.com');
}
...但是我收到以下错误:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://chat.mydomain.com') does not match the recipient window's origin ('https://app.mydomain.com').
有什么想法吗?
附言我在设置中启用了 iframe 集成并启用了 CORS。
【问题讨论】:
标签: javascript reactjs iframe cross-domain