I'm using a filter in order to check if an authorization bearer token is valid. Nevertheless, I'm strugling with the fact that user-agent(firefox, chrome...) is trying to request a CORS OPTIONS request before making the "real" request.
So, my filter intercepts this OPTIONS request, and it has no any authorization bearer token, so it responds with an 4xx http code.
Should I avoid OPTIONS
requests?
private boolean isExcluded(ServletRequest request) {
return ((HttpServletRequest)request).getMethod().equalsIgnoreCase(HttpMethod.OPTIONS);
}
On doFilter
:
if (this.isExcluded(request))
chain.doFilter(request, response);
else
//...
Is this correct?