I am currently working on creating a middleware that can receive CSP reports from browsers. Browsers send these reports with the Content-Type
of application/csp-report
, and the data is in JSON format. Right now, I'm using bodyParser.text
to handle this Content-Type, but I feel like there might be a better way to parse the data as JSON using bodyParser.
Here's my current setup:
app.use(bodyParser.json());
app.use(bodyParser.text({type: 'application/csp-report'}));
My question is, how can I configure bodyParser to accept JSON request payloads with the Content-Type
of application-csp-report
?