Click here to Skip to main content
15,114,888 members
Articles / Web Development
Posted 4 Jun 2017


3 bookmarked

Custom Domains on Google Apps Script

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
4 Jun 2017CPOL
Making your apps script URLs a lot more attractive

It may have occurred to you that when deploying a Google Apps Script web app, the URL spewn forth looks rather long and unattractive:*mashes keyboard*/exec

And that it would be a lot nicer to have something more succinct like:


Well, this has indeed troubled and racked the minds of many a stackoverflow poster trying to circumvent Google’s top-notch cross-domain prevention skills… until now…

It turns out that the solution to hosting Google Apps Script web apps on custom domains has been under our noses for all this time. The secret sauce lies in the setXFrameOptionsMode method in the HtmlService class. It takes an enum of one of two values: DEFAULTor ALLOWALL. What we want to do is to set this to ALLOWALL.

return HtmlService

This now means that we are at liberty to embed our app into any page using an iframe. It even supports SSL.

<iframe src="*mashes keyboard*/exec"></iframe>

And the end result is something quite stunning.

Image 1

Notice how the URL doesn’t take up the entire address bar.

That’s all for today folks. Creds to Stewart for discovering this madness.

Original blog post (by yours truly):


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United Kingdom United Kingdom
Hipster classicist/computer scientist.

London, 16

Comments and Discussions

QuestionWhere to put the XFrameOptionsMode? Pin
Member 1510594618-Mar-21 0:24
MemberMember 1510594618-Mar-21 0:24 
GeneralMy vote of 5 Pin
Gericke Potgieter14-Oct-20 5:19
MemberGericke Potgieter14-Oct-20 5:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.