Tuesday, August 28, 2018

Separating Production and development apps

I had an issue the other day where one of my users logged into a development app accidentally instead of production.

So, I wanted something to let the user know they weren't in production, but not something I'd have to change when I migrated the app to production.

My development and test apps share a domain name, my production is on a separate domain.

Javascript has a helpful function that returns your host name "window.location.hostname"

So, I created a dynamic "onLoad" action on my login page.. with a true action of "Execute Javascript"



2 lines below are all that were needed (replace hostnaame and text as needed)

if (window.location.hostname == "hostname.com")
    window.alert("This is the development system.  Any changes made here will not be made in live.");

Simple and efficient.

Cheers,
Scott


How Generative AI can save you time programming menial tasks

 To paraphrase the rock band Staind, It's been a while since I blogged.  And since every tech blog these days is talking about AI, I fig...