Package Exports
- cloudfront-ip-ranges
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 (cloudfront-ip-ranges) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Cloudfront IP ranges
Get Cloudfront IPs for use in trust proxy configurations.
This package will be updated if Cloudfront ever decides to change the endpoints for retrieving current IPs. We will most likely never see a breaking change for this package.
V2 drops support for Node v8
Install
Requires node 10
or newer, but only LTS are officially supported .
npm install --save cloudfront-ip-ranges
Usage
For use in an Express environment please see Express documentation on trust proxies.
It is recommended to use setInterval
for updating the IP list periodically.
Directly update trust proxies for an Express app
const cfIPranges = require('cloudfront-ip-ranges');
cfIPranges.updateTrustProxy(app);
setInterval(() => {
cfIPranges.updateTrustProxy(app);
}, 1000 * 60 * 60 * 12);
Getting a list of IPs and updating trust proxies manually
Useful if you need to list other proxies alongside the Cloudfront ones.
const cfIPranges = require('cloudfront-ip-ranges');
cfIPranges.updateIPs().then(ips => {
app.set('trust proxy', ['loopback', ...ips]);
});
ES6
You can import the module like so:
import {CloudfrontService} from "cloudfront-ip-ranges";
new CloudfrontService().getIpRange().then( (ips)=> ...);
API
Method | Info |
---|---|
getIpRange | By default returns Promise<string[]> . |
updateTrustProxy | Takes an Express app instance as an argument. Returns Promise<void> . |
Changelog
see CHANGELOG.md