How to embed HTML Service in other sites with iframe

Asked 5 months ago, Updated 5 months ago, 12 views

Create a template HTML in Google Apps Script and display it in doGet.Is it possible to specify the URL of the script in iframe and view it from other sites?



function doGet(){
    return html.evaluate;


2022-09-30 12:01

1 Answers

I don't think I can do it at the moment.
X-Frame-Options can be used to prevent web pages from being embedded in iframes on other sites.
If you try to create and access HTML services, you will see the response header


was included, the app script seems to have various security considerations, and it is also restricted.
There may be conditional permission eventually, and there may already be a way to remove the restriction, but the document does not seem to mention it.

You can embed it in Google Sites, so you want me to do it with that.

You can remove the X-Frame-Options restrictions on sites created by Google Sites in the Google Sites.
Therefore, the Google Sites page itself can be embedded in pages in other domains with iframe.
However, the HTML service embedded in it is still X-Frame-Options:SAMEORIGIN.

The reason why it can be embedded in Google Sites is because HTML services embedded in Google Sites are delivered from the domain, not from
This avoids restrictions on X-Frame-Options:SAMEORIGIN.

This causes the Google Sites portion to appear in the "Google Sites with HTML Services embedded page" and the HTML Services portion to not appear in it.

(These circumstances change from hour to hour, so I don't know how long this will last.Just in case)

2022-09-30 12:01

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.