Skip to content

express middleware to detect if gdpr applies with the help of aws cloudfront

License

Notifications You must be signed in to change notification settings

mairdumont-netletix/express-cloudfront-gdpr

Repository files navigation

NPM version npm module downloads per month

Express Cloudfront GDPR & CCPA Middleware

This package provides a express middleware to detect if GDPR or CCPA applies for a user by inspecting aws cloudfront headers.

Installation / Use in TypeScript projects

npm install @mdnx/express-cloudfront-gdpr --save

Usage

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',
}));

Cloudfront Setup

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"

cloudfront whitelist headers

About

express middleware to detect if gdpr applies with the help of aws cloudfront

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •