This package provides a express middleware to detect if GDPR or CCPA applies for a user by inspecting aws cloudfront headers.
npm install @mdnx/express-cloudfront-gdpr --save
To create a response header with gdpr flag:
import express from 'express';
import { gdprHeaderMiddleware } from '@mdnx/express-cloudfront-gdpr';
const app = express();
app.use(gdprHeaderMiddleware({
headerName: 'X-Gdpr-Applies',
headerTrueValue: '1',
headerFalseValue: '0',
}));
To create a response header with ccpa flag:
import express from 'express';
import { ccpaHeaderMiddleware } from '@mdnx/express-cloudfront-gdpr';
const app = express();
app.use(ccpaHeaderMiddleware({
headerName: 'X-Ccpa-Applies',
headerTrueValue: '1',
headerFalseValue: '0',
}));
In the cloudfront configuration you need to whitelist the following headers to get passed to the express server:
- "CloudFront-Viewer-Country"
- "CloudFront-Viewer-Country-Region"