nestjs whitelist (1) 썸네일형 리스트형 ip filter middleware 🎇middleware 작성 @Injectable() export class IpFilterMiddleware implements NestMiddleware { use(req: Request, res: Response, next: NextFunction) { let allowIps: string[] = []; if (process.env.NODE_ENV == 'local') { allowIps = ['127.0.0.1']; } if (!allowIps.includes(req.ip.toString())) { throw new UnauthorizedException('invalid ip'); } next(); } } 🎇 middleware 주입 # app.module.ts ... export class App.. 이전 1 다음