-
Hello, I'm working with a trame-iframe setup, inspired by these examples. It is an excellent solution to combine an existing frontend with a trame app. Everything functions seamlessly when both the parent and child (iframe) are served from the same origin. However, I encounter difficulties in receiving messages from the iframe when it's not on the same origin. Here is Working Example: Parent:
Child (trame app):
When the trame server is started and I navigate to http://localhost:3000/parent/index.html, everything works as expected, mirroring the functionality in the provided example. However, if I serve the HTML page using a different server (e.g., python3 -m http.server), and access it via http://localhost:8000/, I can send messages to the iframe but am unable to receive messages from it. I'm looking for insights on how to properly enable communication from the trame (iframe) to the parent, when they are on different ports. Any guidance or suggestions would be greatly appreciated! Thank you in advance for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You need to proxy the network through the same domain/origin, which means you will need to enable WebSocket forwarding (ours handle some rewrite which you should not need if you use trame docker) as we do within our docker bundle along with some proxy path forwarding. Also since the trame JS is static, you should be able to serve it along with your main application ( HTH |
Beta Was this translation helpful? Give feedback.
-
Thanks Sebastien! |
Beta Was this translation helpful? Give feedback.
You need to proxy the network through the same domain/origin, which means you will need to enable WebSocket forwarding (ours handle some rewrite which you should not need if you use trame docker) as we do within our docker bundle along with some proxy path forwarding.
Also since the trame JS is static, you should be able to serve it along with your main application (
python -m trame.tools.www
). The only 2 other requests are for starting the process as a POST and the WebSocket. This means, you should just need to add 2 proxy rules to your main web server.HTH