Package Exports
- cloudflare-middleware
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cloudflare-middleware) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cloudflare-middleware
Restores request origin ip to req.origin_ip. Denies other requests.
Usage
let app = express();
app.use(require("cloudflare-middleware")());This is a safer alternative to naively using app.set("trust proxy");, as this checks CloudFlare IP address ranges.
This, however, has been deprecated in favor of the following:
const cloudflareIp = require('cloudflare-ip');
app.set('trust proxy', ip => {
if(ip.startsWith('::ffff:'))
ip = ip.substr(7);
return ip == '127.0.0.1' || cloudflareIp(ip);
});