【问题标题】:Reporting api: Is there a way to debug why reports are failing to uploadReporting api:有没有办法调试报告上传失败的原因
【发布时间】:2020-10-20 07:39:06
【问题描述】:

我正在尝试设置一个带有网络错误日志记录的站点。这使用报告 API 生成和发送有关最终用户体验的报告,并提供对网络问题的较低级别信息的访问权限

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

报告 api 规范:https://w3c.github.io/reporting/

我已经设置了所需的 NEL 和 Report-To 标头,但是当我使用 chrome://net-export 收集日志并查看这些报告的情况时,我注意到报告未能上传到我在 Report-To 中指定的端点(我通过使用 https://netlog-viewer.appspot.com/#reporting 查看我的网络日志,在“上传失败”列下看到这一点)。

是否有任何工具或其他信息可以让我了解失败的原因?我在使用网站时使用 Fiddler 查看网络流量,但没有看到对 nel 端点的任何传出网络调用,因此这告诉我在发送报告之前可能出现故障

这里有任何帮助,谢谢

【问题讨论】:

    标签: google-chrome chromium w3c error-reporting


    【解决方案1】:

    我也遇到过这个问题。我也看到上传失败,但无法理解原因。为了排除不正确的设置问题,我添加了第二个 url 用于报告并为他设置了低优先级。作为第二个网址,我使用了这些人的解决方案 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}
    

    如果浏览器无法上传到https://myurl.org/events,它会将报告上传到https://nickname.report-uri.com url/events。我在 report-uri.com 方面找到了报告,并开始调查我的第一个网址。

    在我的情况下,问题与 CORS 有关。我的预检请求服务器返回带有 * 的响应标头,这不适用于报告 API。这是报告 api 或功能的错误)

    # 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: *
    

    此标头允许所有内容,但不适用于报告 api。服务器必须返回这样的响应才能正确工作报告 api。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-21
      • 2021-09-15
      • 2022-11-21
      • 2011-03-08
      • 2020-10-13
      • 1970-01-01
      • 1970-01-01
      • 2011-06-08
      相关资源
      最近更新 更多