To define a filter that prohibits all cross-origin requests, do the following:
-
Navigate to: <tomcat-directory>\conf\web.xml
-
In web.xml, search for 'Built In Filter Mappings'.
-
In the line above, add this:
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>