server/src/main/java/com/example/server/jwt/JwtAuthenticationEntryPoint.java
<filename>server/src/main/java/com/example/server/jwt/JwtAuthenticationEntryPoint.javapackage com.example.server.jwt;

import io.jsonwebtoken.io.IOException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException {
        // 유효한 자격증명을 제공하지 않고 접근하려 할때 401

        try {
            response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}
