sysend.js
sysend.js copied to clipboard
Any codesandbox or code example for implementing cross domain communications
No, because it's impossible to have Coodesandbox and for example Codepen demo. You would need to add an iframe on those domains that are not possible. To have cross domain communication you need to have your own server that you control, like the one on the two domains I control https://jcubic.pl/sysend.php
But if you want one end I can create a Codepen demo that will send a message to https://jcubic.pl/sysend.php but I'm not sure if this will help you in any way.
Thanks, For cross domain, message is broadcasting from one web server to other but not vice versa. Can you please let me know anything i am missing
It's because you need to have an iframe on both domains, There is open PR #30 but I think it would be a real security issue if the library allows both directions communication when only one page has an iframe. I need to investigate maybe add some API to protect the page that has an iframe on it, so you can specify which domain can receive messages.
If you don't protect the server the attacker can steal potentially sensitive information. Also, the PR breaks old code with two iframes.
Feature of a single proxy HTML file is tracked in #37. The code was moved to the devel branch because the solution in PR was not usable and I was not able to make it work.
It seems that the library stopped working on CodeSandbox. Just tried it to use in the ReactJS project. The module is loaded when the page has already been loaded and the load event handler is not triggered. Which makes the whole library broken. I've tried to debug on CodeSandbox but because Overwrite Panel doesn't work with Service Worker, I was not able to quickly test it.
Sorry for the long delay. It seems that one file for Cross-domain communication is not needed for CodeSandbox since you can create a proxy HTML file on CodeSandbox.
Here is an example of Cross-Domain communication:
https://codesandbox.io/s/proxy-demo-hpfc53?file=/index.html
You need to use demo.html from the repo and run it on port 8000 (I used python3 -m http.server command in sysend repository).
To have two-side communication you need to edit the proxy locally and add domain of the CodeSandbox origin (for me it was "https://hpfc53.csb.app").