Use custom url for HtmlService webapp - google-apps-script

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

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.

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.

I have published web apps working via a Forwarded subdomain with masking. The URL does not change and client side interaction works and is posted back to my files as well. So instead of https://script.google.com/a/bondwood.net/d/1y3iLTLT.... I have mysubdomain.bondwood.net If I want to pass parameters I do have to throw a dummy character is, so mysubdomain.bondwood.net/n?arg1=xyz&arg3=abc
Note that currently any responsive design is being lost via the subdomain but is working via the raw url. This is the only thing I have found to not work at this time.

A CNAME record is an abbreviation for Canonical Name record and is a type of resource record in the Domain Name System (DNS) used to specify that a domain name is an alias for another domain, the "canonical" domain. All information, including subdomains, IP addresses, etc, are defined by the canonical domain. CNAME
But the HTML service lets you serve web pages that can interact with server-side Apps Script functions. HTML Service: Create and Serve HTML
It's a dubious advantage for public pages (not for internal apps).
If you really want to have Google Apps Script Server you need publish a page on a web-server and interact by REST.
Yes, you'll lost Client-side API. Do you really need it?
For an example you can publish a GihHib page Setting up a custom domain with GitHub Pages
Look at my simple app which deploeded on Google Drive Host
Cheers!

Related

What should I put in the meta-tag "google-site-verification" as a content?

I want to add the <meta name="google-site-verification" content="..." /> to my personal project. I've already validated it in Google Search Console and it trowed me a token that I pasted it in the DNS server to complete this validation properly.
Now, what should I put in my index.html as a content property in the meta tag? I asume that it's not safe to copy that same token and put it in the content=<TokenGivenByGoogle> but what should I put instead?
As Google says to copy/paste this code to your HTML code, it is safe to do so.
However, if you already validated your property through DNS, you don't have to do it again in your HTML.

Is it safe to use iframe to prevent malicious files

I am making a web based chatting platform where people can chat and also they can share files. If any hacker inject a malicious file then there is a risk my website maybe got hacked. I am just thinking about embedding the files shared by users from a different domain name with different hosting so the script will look like -
<iframe src="server-url.com?file=filename.ext" ></iframe >
And iframe src URL will response by
<html>
<head></head>
<body>
<img src="filename.ext" >
</body>
</html>
Is this technique prevent my website from getting hacked? If not, what is the best way to protect my website from malicious files?
Now it all depends on the site you are using the iframe attribute for. If the site is secure and has SSL (Referring to the 3rd party site you are iframing) then you should be good.
Now if you did want to make it secure, you could use the "Sandbox" attribute. I have a link below from W3 schools that explains more about it. Sandbox will usually block most content, but there are attribute values that allow you to make exceptions
For example, let's say your iframe chat uses scripts to function, you could do something like this
<iframe src="server-url.com?file=filename.ext sandbox="allow-scripts"></iframe >
Information about iframe sandbox from W3 schools

How to redirect from a html page to a another html page which is on local disk

I am creating an appraisal application to accept apraisal for employees and store in the backend, The first page is a login page ,If user has successfully logged in it should redirect to another page which shows employees information but the catch here is that both pages are on local system ,as the browser runs in sandbox mode window.location is not working,I have tried many other similar options but still it doesn't work,I want to know can I use apache or some other server for this purpose.If yes what would be the way to do it
Use the meta-refresh keyword and supply a path.
somebody add an example, don't have one
I tried window.location.href() and got it to work
Here is the example redirection with meta tag.
<meta http-equiv="refresh" content="0;URL='http://bing.com/'" />

how to redirect a html page to another website which is hosted in google drive urlshorten by gdriv.es

I am new to this.
Can any one tell me why my HTML page which is hosted in Google Drive, cannot redirect to a particular webpage while URL is shortened in GDRIV .
my html file content was
<html>
<body>
<p>you will be redirected soon.</p>
<meta http-equiv="refresh" content="0; url=http://examplesite.com">
</body>
</html>
I shared the Folder to the public and it was working fine, but the URL was bitty flabby like
https#://googledrive.com/host/0BXXXXXXXXXXXXXMGM/site.html
So I shortened the URL with the help of GDRIV
and i got a decent short URL something like
http#://gdriv.es/XXXX/site.html
But the redirecting function is no more working while using the shorten URL and work fine with that clumsy URL
Can any one tell me why this happen and well I think it is irrelevant to ask you tat ' Can i use PHP coding in Google drive hosted sites? '
It works. I did same thing in above example you provided and it did redirect my gdriv.es shortened address to redirected website.
Of course I assume you are aware of typo you made by adding # in your URL.
If it still doesn't work for you there is a "Send Feedback" link at the bottom of gdrive.es main page.
Fill that form and I'm sure they'll check that problem.
For your second question: No, you can not use PHP or any other server side scripting language on Google Drive Hosted Web Sites.
However you can use Google Apps Script which works under Google Drive and it uses Javascript language. You can do many things with GAS, one of them provides you a facility similar to PHP: HTML Service.
One caveat though: It has a javascript sanitization mechanism called CAJA. Meaning you can't just run any javascript code you like. Check last link for restrictions.

How to add a redirect to a web page where you have limited user priveledges

The company I work for has replaced our previously very flexible website with a much more restrictive "website in a box" technology. I have my web pages hosted on Google Sites and would like to redirect people to those pages. When I attempt to do this via javascript it gets stripped from the page when its saved. I do not have access to the section to attempt the depreciated method of redirecting.
Is there another method available to automatically redirect a customer other than just posting a link in a restricted environment like this?
If you're limited to using HTML to do the redirect, you can use a meta redirect:
<meta http-equiv="refresh" content="0; url=http://example.com/">
Though note that its use is deprecated because it may be disorienting to the user. In addition to the <meta> tag, you can add <link rel="canonical" href="http://example.com/"> to let search engines know that the targeted page is the canonical one.
Edit: if Google Sites won't allow you to change the <head> HTML, the Javascript, or the PHP, then it's time to go searching for solutions within Google Sites itself. One solution that pops up pretty frequently in searches seems to be using a URL Redirect Gadget.
On the page you want to redirect from, click the Edit Page button, then Insert Menu, then More Gadgets. Once there, search for "redirect gadgets" and some widgets that should help will show up.
These instructions are based on advice given in the Google Products forums. I don't have a Google Site myself, so I can't verify that they work.