fix: API 인증 에러 처리 개선 및 요청 로그 강화

- Handler.php: API 라우트는 Accept 헤더 없어도 JSON 응답 반환
- ApiKeyMiddleware: 요청 로그에 헤더 정보 추가 (X-API-KEY, Authorization 마스킹)
- Route [login] not defined 에러 해결
- 인증 실패 시 401 JSON 응답으로 일관성 확보
This commit is contained in:
2025-11-25 09:14:33 +09:00
parent 757c5d901c
commit 3fefb8ce26
3 changed files with 49 additions and 1 deletions

View File

@@ -56,8 +56,10 @@ protected function sendSlackException(Throwable $e): void
public function render($request, Throwable $exception)
{
// API 라우트는 무조건 JSON 응답 (Accept 헤더 없어도)
$isApiRoute = str_starts_with($request->path(), 'api/');
if ($request->expectsJson()) {
if ($request->expectsJson() || $isApiRoute) {
// 422 Unprocessable Entity - Validation 실패
if ($exception instanceof ValidationException) {
return response()->json([