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

Embedding within a cross origin isolated document #650

Closed
tareqdayya opened this issue Apr 30, 2024 · 5 comments
Closed

Embedding within a cross origin isolated document #650

tareqdayya opened this issue Apr 30, 2024 · 5 comments
Labels
new Flag for new issues before someone replies

Comments

@tareqdayya
Copy link

Hello,

I'm trying to embed typeform in a cross-origin isolated document. The request triggered to fetch the iframe doc is blocked by the browser as a result.

One solution would be for you to add the following header to the response document:

Cross-Origin-Resource-Policy: cross-origin

Another is to add the typeform survey without an iframe (using html, js, and css), but I couldn't find a way to do that through the docs so it seems like it's not possible at the moment.

Thanks

@github-actions github-actions bot added the new Flag for new issues before someone replies label Apr 30, 2024
@mathio
Copy link
Contributor

mathio commented Apr 30, 2024

Hi @tareqdayya

add the typeform survey without an iframe (using html, js, and css)

If you need to embed a typeform you need to use either Embed SDK or iframe directly.

embed typeform in a cross-origin isolated document

I am not sure I understand your use case. Can you please provide further explain or provide an example? Thanks.

@tareqdayya
Copy link
Author

tareqdayya commented Apr 30, 2024

Hi @mathio, thanks for the prompt response

If you need to embed a typeform you need to use either Embed SDK or iframe directly.

Correct, We're using the createPopup method from the @typeform/embed package.

I am not sure I understand your use case. Can you please provide further explain or provide an example? Thanks.

Absolutely, the document we're trying to embed the typeform iframe in is served with the following headers:

  'Cross-Origin-Embedder-Policy': 'require-corp',
  'Cross-Origin-Opener-Policy': 'same-origin'

That means that any attempt to embed iframes inside this document will be blocked by the browser:
Screenshot 2024-04-30 at 6 37 45 PM

It would be a bit difficult for me to explain why we do this as it's a lengthy subject, this guide on cross origin isolation however does a good job of summing it up.

The problem should be solved if the iframe is served along with the following response headers:

Cross-Origin-Resource-Policy: cross-origin

as is suggested by Chrome in the blocked response:
Screenshot 2024-04-30 at 6 40 17 PM

@mathio
Copy link
Contributor

mathio commented Apr 30, 2024

Thank you. I will raise this with the team responsible for this and get back to you.

@tareqdayya
Copy link
Author

Hi, @mathio

After further investigation, it seems setting the Cross-Origin-Resource-Policy is not going to be enough. As soon as it's set, chrome starts suggesting to add the Cross-Origin-Embedded-Policy: require-corp since it's a document we're loading.

Setting those headers could break existing embedded subresources on the typeform iframe, e.g. a youtube embed, so proceed with caution.

One potential solution would be to not use iframes and use a script instead. A script only requires a Cross-Origin-Resource-Policy header. If I'm not mistaken, it can still populate the data within the DOM and interact with it in a normal fashion.

@mathio
Copy link
Contributor

mathio commented May 2, 2024

I am sorry to hear this. I am afraid we will not be able to add those headers.

Unfortunately we do not support any other approach than iframe. The JavaScript app that displays the form can not be rendered outside of our infrastructure.

@mathio mathio closed this as completed May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new Flag for new issues before someone replies
Projects
None yet
Development

No branches or pull requests

2 participants