Reporting api: Is there a way to debug why reports are failing to upload

Viewed 171

I'm trying to setup a site with network error logging. This uses the reporting api to generate and send reports about the end user's experience and gives access to lower level information for network issues

NEL spec: https://www.w3.org/TR/network-error-logging/

Reporting api spec: https://w3c.github.io/reporting/

I've setup the required NEL and Report-To headers however when I use chrome://net-export to collect logs and look into what is going on with these reports, I notice that the reports had failed to upload to the endpoint I specified in Report-To (I see this by using https://netlog-viewer.appspot.com/#reporting to view my network log, under the column "Failed Uploads").

Is there any tools or additional info I can get to look into why this failed? I've used Fiddler to look at network traffic while I use my site and I don't see any outgoing network calls to the nel endpoint so that is telling me that maybe something is failing before it sends out the report

Any help appreciated here, thanks

1 Answers

I also faced with this problem. I also see failed uploads, but can't understand reason. For excluding incorrect setting problems, I added second url for reporting and set for him low priority. As second url I used solution from this guys https://report-uri.com

Report-To: {
  "group": "nel-reports",
  "max_age": 86400,
  "endpoints": [
     {"url": "https://myurl.org/events", "priority": 1},
     {"url": "https://nickname.report-uri.com/events", "priority": 2}
 ]}

NEL: {"report-to":"nel-reports", "max_age": 86400}

In case if browser fails to upload to https://myurl.org/events, it uploads reports to https://nickname.report-uri.com url/events. I found reports on report-uri.com side and start investigate my first url.

In my case problem was related with CORS. My server for preflight request returns response headers with *, which not works with reporting API. It is bug of reporting api or maybe feature)

# Browser preflight request
Origin: https://anothermysite.org
Access-Control-Request-Headers: content-type
Access-Control-Request-Method: POST

# My server response
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: *
Access-Control-Allow-Headers: *

This headers allows everything, but not works with reporting api. Server must return response like this for correct working reporting api.

Access-Control-Allow-Origin: https://anothermysite.org
Access-Control-Allow-Methods: POST
Access-Control-Allow-Headers: content-type
Related