Determine if Google Apps Script WebApp is running in / dev mode
Is there a way to determine if the web app is running in dev mode or as the correctly published version?
I tried to get the front end and back end url.
If I ask
window.location.href
on the front side, I don't get the url displayed in the page address bar that ends with / dev or / exec. Instead, I end up with a URL that ends at / userCodeAppPanel - I'm guessing because it has been sanitized.
If I call the backend
ScriptApp.getService().getUrl()
and pass it to the cutting edge, it always shows the / exec url even if the script is in / dev mode.
I wanted to enable or disable DEBUG flags depending on which mode the script was run in.
Any ideas? Thank.
source to share
I needed to determine if a script is in dev mode and cannot find a solution. But work will work here. This requires a manual step every time you publish a production version.
On development stage:
- Set the dev flag to true.
- Code that needs to know about dev / production mode should check this flag.
Before posting:
- Set the dev flag to false.
- Publish a web application.
After publication:
- Set the dev flag back to true.
This will segment the resources used by dev and production versions.
source to share