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

Real-time data update not working in deployed demo site #85

Open
MAX-786 opened this issue Jun 29, 2024 · 8 comments · Fixed by #86
Open

Real-time data update not working in deployed demo site #85

MAX-786 opened this issue Jun 29, 2024 · 8 comments · Fixed by #86

Comments

@MAX-786
Copy link
Member

MAX-786 commented Jun 29, 2024

The deployed site is not recieving the realtime updates, because if you try the main branch locally it works fine but the deployed one doesn't,
I think it is because iframe is not recieving postMessage correctly or maybe it is an issue from frontend side idk, nd i tried to fix it but couldnt. Still looking into it.

@djay
Copy link
Member

djay commented Jun 30, 2024

It's probably some CSP header or iframe security setting.

One thing though is that if realtime updates is not enabled then the UI should not allow add and remove etc to be enabled. and probably there should be a warning to tell the user that updates are not enabled and so you won't see a change until after save. Can maybe split that out to seperate card though?

@djay
Copy link
Member

djay commented Jun 30, 2024

Is it not specifying the frontend domain but using "*" here?

.contentWindow.postMessage({ type: 'FORM', data: form }, '*');

Other stuff talks about timing on adding hte event listening https://medium.com/@crookse/cross-domain-communication-parent-window-and-child-iframe-aaf90fcb3e26

and Cross-Origin-Embedder-Policy

https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

@djay
Copy link
Member

djay commented Jun 30, 2024

@MAX-786 your frontend doesn't have CSP or Cross-Origin-Embedder-Policy so both of those probably need to include the CMS domain to allow messages to be received?

@MAX-786
Copy link
Member Author

MAX-786 commented Jun 30, 2024

So I hope its not an issue with Hydra Side :)
I'll try fix it on the frontend.

Yeppp might be better if somehow we tell the editor if the realtime editing is enabled or not. Lets discuss the 'HOW' in separate issue ig.

@MAX-786
Copy link
Member Author

MAX-786 commented Jun 30, 2024

Is it not specifying the frontend domain but using "*" here?

.contentWindow.postMessage({ type: 'FORM', data: form }, '*');

Yes it had the origin of iframe src as recipient's origin, but the issue was intact so i tried removing it. Guess I'll revert it back to how it was and do the CSP fixing on frontend side.

@djay
Copy link
Member

djay commented Jun 30, 2024

If CSp is the fix then don't forget to document it in the readme

@MAX-786
Copy link
Member Author

MAX-786 commented Jun 30, 2024

Figured it out!
I was already working properly with CSP as i was using origin everywhere and it is already in docs as we ask to give adminOrigin as an argument when they initiate bridge. (no extra docs needed)
The problem here was postMessage type:"FORM" because in the hydra.js it was recieving type:"FORM_TYPE" which was changed in one of the prev commit ( i can't track which one) corrected it now.

@djay
Copy link
Member

djay commented Jul 1, 2024

@MAX-786 getting a new problem now I think

led to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://hydra-nextjs-frontend-git-production-max786s-projects.vercel.app') does not match the recipient window's origin ('https://hydra.pretagov.com').

@djay djay reopened this Jul 1, 2024
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

Successfully merging a pull request may close this issue.

2 participants