I am making a small Web App which sends me reminders based on a URL parameter that it is passed. Currently, I have a personal domain - for argument's sake we'll call it http://somedomain.com
.
I have a subdomain set up in my DNS settings on my domain provider's website so that it redirects to a Google Apps Script published Web Application which is designed to send me the reminder. My workflow is as follows:
- I go to my subdomain at
http://s.somedomain.com
and pass a parameter using?
(for examplehttp://s.somedomain.com?q=medicine
) s.somedomain.com
is set up to redirect to my Apps Script web application located athttps://script.google.com/macros/s/.../exec
:
function doGet(e){
GmailApp.sendEmail('MYEMAIL', 'Reminder: placeholder text', e.parameter.q);
return HtmlService.createHtmlOutput("✔️ Sent");
}
The workflow works great in so much as the redirects all work and I end up at a page that just says ✔️ Sent
.
The issue here however, is that when I go to s.somedomain.com?q=medicine
I get automatically redirected to s.somedomain.com/?q=medicine
(with a /
after the top level domain) which completely breaks the script, as the parameter is being passed to my root directory before redirect, causing the redirect to head to:
https://script.google.com/macros/s/.../exec/?q=medicine
and not:
https://script.google.com/macros/s/.../exec?q=medicine
I'm not 100% sure whether this is an issue with my DNS forward, or whether I will need to point my domain to a page and handle the parameters that way, or whether this can be done in Apps Script by trying to get the parameters after the trailing /
.
My domain provider is ionos (formerly 1and1), and my destination settings are as can be seen below, under Domains & SSL > Subdomains > s.somedomain.com > Adjust Destination > Forward Domain.