Spring Interceptor에서 PreFlight Request (CORS 인식을 위한 OPTIONS 요청)에 대해서 HandlerMethod로 케스팅 한 경우 발생.
해결 방법은 instanceof로 체크 하면 됨
----
관련 자료)
PreFlightHandler 클래스
private class PreFlightHandler implements HttpRequestHandler {
private final CorsConfiguration config;
public PreFlightHandler(CorsConfiguration config) {
this.config = config;
}
@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
corsProcessor.processRequest(this.config, request, response);
}
}
PreFlightHandler를 사용하는 메소드
AbstractHandlerMapping.getCorsHandlerExecutionChain
Update the HandlerExecutionChain for CORS-related handling.
For actual requests, the default implementation inserts a HandlerInterceptor that makes CORS-related checks and adds CORS headers.
pre-flight requests는 무엇인가?
A CORS preflight request is a
CORS request that checks to see if the
CORS protocol is understood and a server is aware using specific methods and headers.
A preflight request is automatically issued by a browser and in normal cases, front-end developers don't need to craft such requests themselves. It appears when request is qualified as
"to be preflighted" and ommited for
simple requests.
For example, a client might be asking a server if it would allow a
DELETE
request, before sending a
DELETE
request, by using a preflight request:
댓글
댓글 쓰기