A simple middleware that adds a convenience property for the users Do-Not-Track preference.
const express = require('express')
const expressDnt = require('express-dnt')
const app = express()
app.use(expressDnt())
app.get('/', (req, res) => {
res.end(`Do not track enabled: ${req.dnt}`)
// req.dnt is either true or false
})
const express = require('express')
const expressDnt = require('express-dnt')
const app = express()
app.use(expressDnt('doNotTrack')) // Pass a string with the custom property name
app.get('/', (req, res) => {
res.end(`Do not track enabled: ${req.doNotTrack}`)
})