Skip to content

Commit

Permalink
fix issue in header
Browse files Browse the repository at this point in the history
  • Loading branch information
bahram1249 committed Feb 27, 2024
1 parent e4f5635 commit 114fa71
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { Request, Response, NextFunction } from 'express';
export class ChobokanRealIpMiddleware implements NestMiddleware {
constructor(private config: ConfigService) {}
use(req: Request, res: Response, next: NextFunction) {
if (req.headers['REAL_IP'] != null) {
req.ips.push(req.headers['REAL_IP'].toString());
} else if (req.headers['REMOTE_ADDR'] != null) {
req.ips.push(req.headers['REMOTE_ADDR'].toString());
if (req.headers['x-real-ip'] != null) {
req.ips.push(req.headers['x-real-ip'].toString());
} else if (req.headers['x-forwarded-for'] != null) {
req.ips.push(req.headers['x-forwarded-for'].toString());
}
next();
}
Expand Down

0 comments on commit 114fa71

Please sign in to comment.