gradio
gradio copied to clipboard
Communication between gradio(iframe) and the parent site
I am using an iframe to embed my gradio app, but how can I make communication between my parent app and gradio app? https://stackoverflow.com/questions/9153445/how-to-communicate-between-iframe-and-the-parent-site From this link, I tried to send message from parent website to this iframe (gradio app) But I don't see any possible way to get that message in gradio.
We need more information about what you are trying to do.
Thanks for replying @pngwn So I have a Laravel + React web application and I have a gradio app embed inside an iframe in one of React page. I would like to pass username (authenticated username) from react or laravel => gradio. So that I can keep logging of who used my gradio app when they click on a button in gradio app or at some point. I have couple of approaches in my mind like
-
if I try to pass username as query parameter e.g
http://localhost:5000/&username=john
I want to getjohn
in my gradio app -
I tried to use window.postMessage https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage so that I can send a message from parent website to gradio iframe app but how can I get that message in gradio app?
Please help me :pray:
Hi @SmartDever02 can you please provide a minimal code example that we can use to reproduce the issue above? See: https://stackoverflow.com/help/minimal-reproducible-example
Will close for now, but happy to reopen with more details. If you can please share the code of what approach you tried, and what happened vs. what you expected, that'll help us look into this.
@SmartDever02 Did you find a way to pass authentification data to an embedded gradio iframe?
@ccharest93 I setup fast api server and mounted different gradio apps with different routes. and then for different users, I embed different gradio apps with different slugs in the route. e.g let say I have users and I have unique id for the users right? like uuid With that uuid I mount a new gradio app and embed it in my website. No authentication data passed to the iframe and I use uuid from the route path as identifier.