File tree Expand file tree Collapse file tree
packages/crowdsec-http-middleware Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ const middlewareOptions: ICrowdSecHTTPMiddlewareOptions = {
104104 },
105105 // here, an optional function to extract Ip from request
106106 // you can also use a scenario with "extractIp" capability
107+ // getCurrentIp is prior to scenarios extractIp . If you want to use a default function, create a scenario with only extractIp
107108 getCurrentIp : (req : IncomingMessage ) => req .socket .remoteAddress || ' 0.0.0.0' ,
108109 // we will see this configurations later
109110 watcher: watcherOptions ,
Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ export class CrowdSecHTTPMiddleware extends CommonsMiddleware {
8888 return this . ipObjectCache . getIpObjectWithCache ( ip ) ;
8989 }
9090
91- protected middlewareFunction = ( req : IncomingMessage , res : ServerResponse ) => {
91+ protected middlewareFunction = ( req : IncomingMessage , res ? : ServerResponse ) => {
9292 const currentIp = this . getIpObjectFromReq ( req ) ;
9393
9494 if ( ! currentIp . addressMinusSuffix ) {
@@ -101,7 +101,7 @@ export class CrowdSecHTTPMiddleware extends CommonsMiddleware {
101101
102102 this . watcher ?. middleware ( currentIp . addressMinusSuffix , req ) ;
103103
104- if ( this . options . protectedByHeader ) {
104+ if ( this . options . protectedByHeader && res ) {
105105 res . appendHeader ( 'X-Protected-By' , 'CrowdSec' ) ;
106106 }
107107 } ;
You can’t perform that action at this time.
0 commit comments