Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cherry/network-error-logging
Middleware for setting the NEL HTTP response header
https://github.com/cherry/network-error-logging
express hacktoberfest middleware nel network-error-logging
Last synced: 3 months ago
JSON representation
Middleware for setting the NEL HTTP response header
- Host: GitHub
- URL: https://github.com/cherry/network-error-logging
- Owner: Cherry
- License: mit
- Created: 2018-11-17T18:47:51.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-11-25T13:01:51.000Z (3 months ago)
- Last Synced: 2024-11-27T03:34:22.376Z (3 months ago)
- Topics: express, hacktoberfest, middleware, nel, network-error-logging
- Language: JavaScript
- Homepage:
- Size: 1.31 MB
- Stars: 5
- Watchers: 3
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Network Error Logging
==============
[](https://badge.fury.io/js/network-error-logging)
[](https://david-dm.org/Cherry/network-error-logging)
[](https://github.com/Cherry/network-error-logging/actions)
[](https://coveralls.io/github/Cherry/network-error-logging?branch=main)
[](https://app.fossa.io/projects/git%2Bgithub.com%2FCherry%2Fnetwork-error-logging?ref=badge_shield)This is Express middleware to set the `NEL` HTTP response header. You can read more about it [here](https://www.w3.org/TR/network-error-logging/#nel-response-header).
To use:
```javascript
const NEL = require('network-error-logging')// ...
app.use(NEL({
report_to: 'endpoint-1', // REQUIRED to register. OPTIONAL if intention is to remove a previous registration. defined in the Report-To header
max_age: 31_536_000, // REQUIRED. seconds
include_subdomains: true, // OPTIONAL
success_fraction: 0.5, // OPTIONAL. sampling rate
failure_fraction: 0.5, // OPTIONAL. sampling rate
request_headers: ["If-None-Match"], // OPTIONAL. request headers whose names and values are included in the network error reports
response_headers: ["ETag"] // OPTIONAL. response headers whose names and values are included in the network error reports
}))
```
For further documentation on each field, see https://w3c.github.io/network-error-logging/#nel-response-header.This header is best set with a previously defined `Report-To` group. [This module](https://github.com/Cherry/report-to) is a great way to do that.
https://report-uri.com/ is a great reporting platform for monitoring CSP, NEL, etc. error logs.
## License
[](https://app.fossa.io/projects/git%2Bgithub.com%2FCherry%2Fnetwork-error-logging?ref=badge_large)