Skip to content

Files

Latest commit

196682d · Jan 7, 2020

History

History
51 lines (36 loc) · 1.63 KB

README.md

File metadata and controls

51 lines (36 loc) · 1.63 KB

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