@anonymous-piwik-user opened this Issue on January 7th 2014

Hi,

if you request the JS tracking Code via the API and the 'piwikUrl' Parameter isn't set, Piwik tries to recognize the correct URL. This is done in plugins/SitesManager/API.php function getJavascriptTag:

if (empty($piwikUrl)) {
    $piwikUrl = Url::getCurrentUrlWithoutFileName();
}

In times where we're trying to slowly migrate to IPv6 this is really bad! Piwik should use the DNS name, not the IP.

Request:

http://example.org/piwik/?module=API&method=SitesManager.getJavascriptTag&idSite=1&period=&date=&filter_limit=&token_auth=abcdefghij12354687&expanded=&format=PHP

Response:

s:880:"<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://2a02:8070:8360:xxxx:xxxx:85b0:xxxx:xxxx/piwik/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', 1]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
    g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();

</script>
<noscript><p><img src="http://2a02:8070:8360:xxxx:xxxx:85b0:xxxx:xxxx/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
";

It would be great if someone with real understanding of Piwik and PHP could fix this.

Thanks in advance!

@robocoder commented on January 7th 2014 Contributor

Check the trusted_hosts setting in your config.ini.php. The fallback to the server address happens if the value of the Host: header isn't in the trusted_hosts list.

This Issue was closed on January 7th 2014
Powered by GitHub Issue Mirror