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);
}
After testing an architecture of a security rest service built-in Spring Framework and a web application on AngularJS which over a POST gets credentials and regard information for the front end part, using firebug I discover and error after a submit on each event:
Cross-Origin
Request Blocked: The Same Origin Policy disallows reading the remote
resource at http://localhost:8081/keepnotes-soa-app/rest/user. (Reason:
CORS header 'Access-Control-Allow-Origin' missing).
Reviewing on Internet I discovered a missing configuration over my Front-end application which is the result of having a separated application, so on I have to create the following lines:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Having created the filter class we must to make the configuration over web.xml with the following lines:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters