Use this code to generate your serviceurl
function getUrl(sUrl){
if (sUrl == '')
return sUrl;
if (window.location.hostname == 'localhost'){
return "proxy" + sUrl;
}else {
return sUrl;
};
}
var serviceUrl = getUrl('/sap/opu/odata/sap/Z_INSPECTIONS_SRV/');