BREAKING CHANGE: Support trust proxy and frameworks other than Express#2
Open
paulmelnikow wants to merge 1 commit intomasterfrom
Open
BREAKING CHANGE: Support trust proxy and frameworks other than Express#2paulmelnikow wants to merge 1 commit intomasterfrom
paulmelnikow wants to merge 1 commit intomasterfrom
Conversation
Collaborator
Author
|
Hey @cchan, wanna review this before I merge it? |
Member
|
True! Give me a min |
Member
|
Two comments, otherwise looks good! |
Collaborator
Author
|
They're not showing up. Are they still in draft? |
Collaborator
Author
|
@cchan could you check if your comments are still in draft? |
cchan
reviewed
Oct 25, 2020
|
|
||
| function middleware(options) { | ||
| return function (req, res, next) { | ||
| if (isCloudflare(trimIp(req.ip))) { |
Collaborator
Author
There was a problem hiding this comment.
Oops! Good catch.
| next(); | ||
| }else{ | ||
| res.end(); | ||
| function trimIp(ip) { |
Member
There was a problem hiding this comment.
Maybe trim4Mapped6?
Future would be nice to have proper ipv6 support.
Member
|
Ooops fixed! Exposed that I haven't used github reviews before xD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds convenient support for trust proxy (without depending on a deprecated package) and adds an exported
isMiddlewarefunction that can be used with other frameworks.We could avoid the major version bump by exporting
middlewarealthough I think it's just as well to call this 2.0.0 since trust proxy is the recommended method.I've also added a code formatter which formats both the code and the readme examples.