Web applications opt in to this behavior with the NEL header, which is a JSON-encoded object:
NEL: { "report_to": "nel",
"max_age": 31556952 }
An origin considered secure by the browser is required.
The following object keys can be specified in the NEL header:
- report_to
-
The reporting API group to send network error reports to (see below).
- max_age
-
Specifies the lifetime of the policy, in seconds (in a similar way to e.g. HSTS policies are time-restricted). The referenced reporting group should have a lifetime at least as long as the NEL policy.
- include_subdomains
-
If true, the policy applies to all subdomains under the origin that the policy header is set. The reporting group should also be set to include subdomains, if this option is to be enabled.
- success_fraction
-
Floating point value between 0 and 1 which specifies the proportion of successful network requests to report. Defaults to 0, so that no successful network requests will be reported if the key is not present in the JSON payload.
- failure_fraction
-
Floating point value between 0 and 1 which specifies the proportion of failed network requests to report. Defaults to 1, so that all failed network requests will be reported if the key is not present in the JSON payload.
The reporting group referenced above is defined in the usual manner within the Report-To
header, for example:
Report-To: { "group": "nel",
"max_age": 31556952,
"endpoints": [
{ "url": "https://example.com/csp-reports" }
]
}