javascript - How to assign a value to a a JS variable in a web site depending if it's running locally or in production? -
I work on a web project on my laptop. When I am doing, I can upload my files to production. Every time I upload to the output, I have to make sure that I change the URL of the product URL into my URL URL. For example:
var ping_url = 'http: /10.10.128.233' // locally // var ping_url = 'http://ping.service.com' // in production
I have 3 urls in different parts of the code, I often forget to change the output before uploading it, and as a result I break the production website.
Is there any way to check that I am running a website in a laptop or production?
I want to write:
If (local) {var ping_url = 'http://10.10.128.233' // locally} and {var ping_url = 'Http://ping.service.com' // In Production}
Any ideas?
You can always check and compare it 'localhost'
or whatever You also use hostnames on your laptop, for example
var ping_url = ~ location.hostname.indexOf ('localhost')? 'Http://10.10.128.233': 'http://ping.service.com'
Comments
Post a Comment