Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use custom url for HtmlService webapp

Is there a way to use a specific cname to run a Htmlservice webapp ? I would like to user something like app.domain.com to run the htmlservice app.

I see that this works inside a Google Site but the Google site doesn't manage correctly the tags

like image 754
Benoit Avatar asked Sep 18 '25 00:09

Benoit


2 Answers

Not possible. At most you can use your custom url and program it to redirect to your apps script webapp. That way its easy to type and remember.

like image 66
Zig Mandel Avatar answered Sep 20 '25 01:09

Zig Mandel


The solution posted by @Karl_S works with the published /exec urls but not with the /dev ones. Furthermore the responsive design is lost because the frame redirect skips the viewport setting in the html wrapper. An alternative would be to host the wrapping html page on your domain and add the viewport setting in the head while keeping the rest what the frame redirect does. For example the following worked for me:

<html><head>
  <title>My App</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">   
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <frameset rows="100%">
  <frame src="https://script.google.com/a/.../exec" 
         title="My App" 
         frameborder="0" 
         noresize="noresize">
  </frameset>
</html>

Also make sure to publish your script with cross domain restriction disabled, i.e. In your script ensure you call

HtmlService.createTemplateFromFile(...)
  .evaluate()
  .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)

Hope it helps someone.

like image 44
rehan Avatar answered Sep 20 '25 02:09

rehan