How do I enable support for CORS?

First, stop the SearchBlox Server before you enable CORS Support. Then, take the following steps:
 
1.) Download the two jar files and place them within the /webapps/searchblox/WEB-INF/lib/ folder:
 
 
2.) Back up the existing web.xml file under /webapps/searchblox/WEB-INF/
and replace the file with the one downloaded from link below
 
After replacement restart the SearchBlox Server. CORS is enabled for all domains now. If this is working correctly, you can add the required URLs within cors.allowOrigin parms to restrict it to the required domains. 

Otherwise
Please add the following in web.xml before first <listener> tag at line no 60

<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
<!-- Note: All parameters are options, if omitted the CORS
Filter will fall back to the respective default values.
-->
<init-param>
<param-name>cors.allowGenericHttpRequests</param-name>
<param-value>true</param-value>
</init-param>

<init-param>
<param-name>cors.allowOrigin</param-name>
<param-value>*</param-value>
</init-param>

<init-param>
<param-name>cors.allowSubdomains</param-name>
<param-value>false</param-value>
</init-param>

<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>GET, HEAD, POST, OPTIONS</param-value>
</init-param>

<init-param>
<param-name>cors.supportedHeaders</param-name>
<param-value>*</param-value>
</init-param>

<init-param>
<param-name>cors.exposedHeaders</param-name>
<param-value>X-Test-1, X-Test-2</param-value>
</init-param>

<init-param>
<param-name>cors.supportsCredentials</param-name>
<param-value>true</param-value>
</init-param>

<init-param>
<param-name>cors.maxAge</param-name>
<param-value>3600</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Invocation context filter</filter-name>
<url-pattern>/servlet/AdServlet</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

Have more questions? Submit a request

Comments