I am facing a strange problem with Tomcat 8 and CORS. I am developing a Hybrid web app using ionicframework, AngularJS, Cordova as front end and Tomcat 8 and Spring 3 as back-en
I did more research on this and figure out the issue.If you see the headers from Android and look into Origin Header.
Origin: file://
Tomcat CORS filter tries to validate the URI in Origin header and considers "file://" as an invalid URI and returns back 403.
*/
protected static boolean isValidOrigin(String origin) {
/* // Checks for encoded characters. Helps prevent CRLF injection.
if (origin.contains("%")) {
return false;
}
URI originURI;
try {
originURI = new URI(origin);
} catch (URISyntaxException e) {
return false;
}
// If scheme for URI is null, return false. Return true otherwise.
return originURI.getScheme() != null;
*/
return true;
}
I need to dig more on why Android is sending the incorrect URI.