Skip to content

Instantly share code, notes, and snippets.

@carlosleonam
Last active September 30, 2021 15:04
Show Gist options
  • Save carlosleonam/5049aaba34a35d5ea404193424ae2577 to your computer and use it in GitHub Desktop.
Save carlosleonam/5049aaba34a35d5ea404193424ae2577 to your computer and use it in GitHub Desktop.
Check if HOST is local (localhost) or remote (WEB)

Check if HOST is local (localhost) or remote (WEB)

Put below code in your JS file:

// Check is LOCAL
if (window.location.host.replace(/(localhost|127\.0\.0\.1)(:\d+)?/i, "") == '') {
    // youtr code here

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment