I am using the new Google Sites and have a Google Apps Script on the side for it. I outputed some HTML like so:
function doGet() {
return HtmlService
.createTemplateFromFile('index')
.evaluate()
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
Then I head over to the Google Site and do:
Insert -> Embed -> By URL
I insert a url like so:
https://script.google.com/macros/s/*mashes keyboard*/exec
Now I head over to:
https://sites.google.com/view/myexamplesite
Voila! I see my embedded app script just like I dreamed of. Now here is where it gets sad. Next I head back to the site editor and add my very own custom domain from Google domains. Then I head over to:
https://www.myexamplesite.com
Now the embedded Google Apps Script has an error like so:
script.google.com refused to connect.
and in the console logs:
Refused to display 'https://script.google.com/macros/s/*mashes keyboard*/exec' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
That sucks . . . .
So I try and embed my own iframe in the embed option instead of By URL
like so:
<iframe
width="100%"
src="https://script.google.com/macros/s/*mashes keyboard*/exec">
</iframe>
Now I head over to the site and it looks god awful and I started having nightmarish flashbacks of long drawn out battles with iframes
. I did read somewhere, now I can't find the reference, Google Sites does load the Apps Script a special way because they are both Google, hence why the By URL
option worked so well and looked nice.
I have the Apps Script project connected to a Google Console project owned by a Google IAM org that is the connected with the domain. Yet nothing let's me change the URL for the Apps Script.
Any Ideas on how to get the embed by URL option to work right with a custom domain? Can I get the Apps Script Project to be part of the same domain so it is same origin? Do I just have to bite the bullet and do lots o css to hack it in the iframe?