The Java servet filter for enabling CORS (cross-domain) web applications received a major upgrade today.
Up until now in order to change the out-of-the-box CORS configuration you had to add filter init-params in the web.xml descriptor of your application. A number of developers asked for alternative configuration means, such as specifying a properties file for the configuration. This is now supported.
The CORS Filter will now apply the following precedence when resolving the configuration:
- Checks for an environment variable “cors.configurationFile” pointing to a properties file with the CORS configuration.
- Checks for a servlet filter init-param “cors.configurationFile” pointing to a properties file with the CORS configuration.
- Checks for CORS params in filter init section, applies the default values if not found.
Another important configuration change is the ability to specify a general “allow-any-request-header” policy by setting the cors.supportedHeaders to an asterisk.
Thanks to David Bellem, Stijn Cremers and Casey Lucas for initiating this new release of the CORS Filter. Also thanks to Anne van Kesteren for answering my CORS-related query on the W3C list.