Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the example js-trame cant work. addEventListener on iframe node contentwindow will be stop by CORS #1

Open
ylwbl opened this issue Dec 26, 2023 · 10 comments

Comments

@ylwbl
Copy link

ylwbl commented Dec 26, 2023

Send message from js to trame is Ok, but when I try to send message from trame to js, it didn't work.
1703572970226
Maybe there's a problem in the example js-trame
1703573374205
it seems that postMessage in iframe should like that
window.parent.postMessage(message)
so at the outside, I can receive message like this:
window.addEventListener
or there is another way to solve this problems?

@jourdain
Copy link
Collaborator

Did you look at that example https://github.com/Kitware/trame-iframe/tree/master/examples/trame-js?

Moreover to prevent cross origin issue, you need to be in the same domain.

@ylwbl
Copy link
Author

ylwbl commented Dec 27, 2023

Did you look at that example https://github.com/Kitware/trame-iframe/tree/master/examples/trame-js?

Moreover to prevent cross origin issue, you need to be in the same domain.

Thank you for your reply.I have looked at that example,but it didn't solve my problem.
I am now creating a iframe in a vue application to show the trame render,its two application and will run on two different port,even differnet server.
Under the circumstances,I need to communicate between trame and my application.
Do you have an idea to make js-trame works right? now the example cant work right

@jourdain
Copy link
Collaborator

It is expected to run across several servers, but people tends to put a proxy in front of it so it all appear to come from a single server.

@marospekarik
Copy link

marospekarik commented Mar 11, 2024

I'm also uncertain if I've correctly understood this example.

I have tried to run the TRAME server on AWS and set up a temporary Ngrok HTTPS link for testing. Then, from my local computer, I added the link to an iframe. I expected that communication would be bidirectional, but it isn't. While I can successfully send messages from the iframe (on my local PC) to the server, I am not receiving messages back from the server (on slider or button events).

@jourdain
Copy link
Collaborator

Which example are you referring to? js-trame or another one?

@marospekarik
Copy link

marospekarik commented Mar 12, 2024

Yes, js-trame @jourdain

@jourdain
Copy link
Collaborator

jourdain commented Mar 12, 2024

Can you provide more information then, is everything running on the same domain and port?

@marospekarik
Copy link

No, they are on different domains. Trame server is running on the AWS instance as I mentioned above. Then, I am using ngrok to forward the Trame server (8080) to the internet for testing purposes. Then, I have an iframe with the ngrok URL on my local client.

I aim to have a Trame server on an AWS instance and perform bi-directional communication from a web client sitting somewhere else.

@marospekarik
Copy link

I can successfully send messages from the client to the Trame server on AWS, but I don't see any message when I try to send it from the server back to the client.

@jourdain
Copy link
Collaborator

That is expected when you don't share the same domain. You need to put a proxy in front of your services to expose them under the same domain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants