There are some solutions to this common problem -
1) Use $.post('./timer/check')
. This will take the current domain and append the url (RECOMMENDED)
2) Create a global variable and use it wherever you want. Assign local url when working on dev and assign prod url when working on production.
3) Create a wrapper and always use that wrapper to send the request. Create a global variable with your current status(Dev or Prod) as it's value and keep changing it. And use it Like this-
post(url) {
var baseurl = '';
if(CURRENT_ENVIRONMENT=='DEV')
baseurl = 'http://localhost:8080';
else if(CURRENT_ENVIRONMENT=='PROD')
baseurl = 'http://yourwebsiteurl';'
$.post(baseurl+'/timer/check')
//and so on
}
You can use whichever you prefer.