From 758ce2b98853a329a3075e94c3b996a685958410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Fri, 23 Jan 2026 21:08:52 +0900 Subject: [PATCH] =?UTF-8?q?feat(api):=20=ED=8A=B9=EC=A0=95=20IP=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=20=EC=8A=AC=EB=9E=99/=EB=A1=9C=EA=B7=B8=20=EC=A0=9C?= =?UTF-8?q?=EC=99=B8=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - EXCEPTION_IGNORED_IPS 환경변수로 무시할 IP 목록 관리 - 해당 IP에서 '회원정보 정보 없음' 예외 발생 시 슬랙/로그 건너뜀 - 사무실/개발자 IP에서 발생하는 불필요한 알림 방지 Co-Authored-By: Claude --- app/Exceptions/Handler.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 434d377..83bdeef 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -16,8 +16,38 @@ class Handler extends ExceptionHandler { + /** + * 특정 IP에서 발생하는 예외를 슬랙/로그에서 무시할지 확인 + */ + protected function shouldIgnoreException(Throwable $e): bool + { + $ignoredIps = array_filter( + array_map('trim', explode(',', env('EXCEPTION_IGNORED_IPS', ''))) + ); + + if (empty($ignoredIps)) { + return false; + } + + $currentIp = request()?->ip(); + + // 무시할 IP 목록에 있고, '회원정보 정보 없음' 예외인 경우 + if (in_array($currentIp, $ignoredIps, true)) { + if ($e instanceof AuthenticationException && $e->getMessage() === '회원정보 정보 없음') { + return true; + } + } + + return false; + } + public function report(Throwable $e): void { + // 무시할 예외인 경우 슬랙/로그 모두 건너뜀 + if ($this->shouldIgnoreException($e)) { + return; + } + try { if ( app()->environment('local') || app()->environment('production')