There is a common error under rest service development with AngularJS framework after that understood that internally the framework do OPTIONS requests to know who is invoking an error like follows can occur:
Response for preflight has invalid HTTP status code 400
The possible solution to this problem is to check CORSFilter and when the request contains a OPTIONS just respond an OK status:
...
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK);
} else {
chain.doFilter(req, res);
}
Important links:
- http://www.concretepage.com/spring-4/spring-4-rest-cors-integration-using-crossorigin-annotation-xml-filter-example
- http://corpus.hubwiz.com/2/angularjs/23786722.html
- http://websystique.com/spring-security/secure-spring-rest-api-using-oauth2/
- http://zhentao-li.blogspot.mx/2012/06/enable-cors-support-in-rest-services.html
No comments:
Post a Comment