Piwik action reports fail on https sites in firefox 3.5+ due to cross-domain XHR
| Project: | Piwik - Web analytics |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Firefox 3.5+ implements W3C XHR, which involves some trickery for AJAX requests. Basically, cross-domain requests are preceeded by an OPTIONS request to validate the server, which piwik does not support. Piwik reports currently only uses the 'http' version of the provided piwik server. Firefox considers http://domain and https://domain to be different and pre-flights the request, which piwik fails to support, and thus the ajax requests fail when the site is viewed in https.
Some background from http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
The CORS standard works by adding new HTTP headers that allow servers to serve resources to permitted origin domains. Browsers support these headers and enforce the restrictions they establish. Additionally, for HTTP request methods that can cause side-effects on user data (in particular, for HTTP methods other than GET, or for POST usage with certain MIME types), the specification mandates that browsers “preflight” the request, soliciting supported methods from the server with an HTTP OPTIONS request header, and then, upon “approval” from the server, sending the actual request with the actual HTTP request method. Servers can also notify clients whether “credentials” (including Cookies and HTTP Authentication data) should be sent with requests.
For sites where piwik is a subdirectory, like mine, the fix is to use the http or https version of the URL depending on the current site context. I don't think there would be a proper solution for sites where piwik is actually a different URL. Would you be interested in a patch that solves the former but not the latter?

#1
Have you seen the "Known issue"? Piwik reports is currently more or less broken and the reason is that the Piwik developers have broken it. See the case at http://dev.piwik.org/trac/ticket/283.
Nevertheless, please provide a patch.