Z-Ray keeps adding a weird script tag on each script

General discussion forum for the Zend Server
Post Reply
Posts: 5
Joined: Thu Sep 01, 2016 1:45 am

Z-Ray keeps adding a weird script tag on each script

Post by reyn2680 » Thu Jan 12, 2017 10:17 pm

I have installed Z Ray standalone and it's working but is breaking my application. Any time I load a page I can see the following error:

Code: Select all

Uncaught ReferenceError: appi18n is not defined
    at getTranslation (app.js?1484235674:1945)
    at HTMLDocument.<anonymous> (app.js?1484235674:1512)
    at i (jquery-1.12.4.min.js?1474472239:2)
    at Object.fireWith [as resolveWith] (jquery-1.12.4.min.js?1474472239:2)
    at Function.ready (jquery-1.12.4.min.js?1474472239:2)
    at HTMLDocument.K (jquery-1.12.4.min.js?1474472239:2)
The problem is caused by Z Ray adding the following script code on each .js file found on the page:

Code: Select all

<!-- Zend Z-Ray header -->
<script type="text/javascript">(function(){function gl(href){var match=href.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);return match&&{host:match[2]}}var po=new gl(document.URL);var srh=XMLHttpRequest.prototype.setRequestHeader;XMLHttpRequest.prototype.setRequestHeader=function(header,value){srh.call(this,header,value);if(!this.headers){this.headers={}}if(!this.headers[header]){this.headers[header]=[]}this.headers[header].push(value)};var o=XMLHttpRequest.prototype.open;var reloadData=false;XMLHttpRequest.prototype.open=function(method,url,async,user,pass){o.call(this,method,url,async,user,pass);var p=new gl(url);if(url.indexOf('ZRayDisable=1')<0){if(p.host==undefined||p.host==po.host){if(typeof this.headers==='undefined'||typeof this.headers['ZRAY-ID']==='undefined'){this.setRequestHeader('ZRAY-ID','7@2276@1484248110@0')}reloadData=true}}};var s=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.send=function(data){var orsc=this.onreadystatechange;this.onreadystatechange=function(){if(typeof orsc=='function'){orsc(this)}if(this.readyState==4&&reloadData){reloadData=false;if(document.addEventListener){var e=document.createEvent('HTMLEvents');e.initEvent('ReloadDevBar',true,true);document.dispatchEvent(e)}}};s.call(this,data)}})();</script>
<!-- Zend Z-Ray header end -->
The same is also added just after the head tag. How I can fix this issue and continue using Z Ray properly?

User avatar
Posts: 285
Joined: Thu Jan 22, 2009 3:16 pm

Re: Z-Ray keeps adding a weird script tag on each script

Post by zend_eyalt » Mon Jan 23, 2017 12:35 pm

Normally when JS scripts are served, they come with Content-Type header such as : text/javascript which would prevent Z-Ray from being injected.

Could you please check (via chrome dev tools for instance), with which Content-Type header you're JS files are being served ?

Post Reply