This is a blatant rip-off from Mariano Guerra’s Blog on enabling CORS in Apache Solr amd he got it from Stack overflow but I look this up on a regular bases so now I added it to my own cheat-sheets. 🙂Add the following XML before the existing filter section in server/solr-webapp/webapp/WEB-INF/web.xml:
<filter> <filter-name>cross-origin</filter-name> <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class> <init-param> <param-name>allowedOrigins</param-name> <param-value>http://localhost*</param-value> </init-param> <init-param> <param-name>allowedMethods</param-name> <param-value>GET,POST,DELETE,PUT,HEAD,OPTIONS</param-value> </init-param> <init-param> <param-name>allowedHeaders</param-name> <param-value>origin, content-type, cache-control, accept, options, authorization, x-requested-with</param-value> </init-param> <init-param> <param-name>supportsCredentials</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>chainPreflight</param-name> <param-value>false</param-value> </init-param> </filter> <filter-mapping> <filter-name>cross-origin</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>