Enable CORS

Cross-Origin Resource Sharing (CORS) setup controls which external websites or domains are allowed to make requests to your SearchBlox server. Setting this up correctly ensures that only trusted domains can access your search API.

Enable CORS for specific Domains

Before making any changes, locate the web.xml configuration file on your system using the path based on your operating system:

File Location
Windows:
C:\SearchBloxServer\webapps\ROOT\WEB-INF\web.xml
Linux:
/opt/searchblox/webapps/ROOT/WEB-INF/web.xml

To allow single domain, edit as shown below:

<init-param>
 		<param-name>cors.allowOrigin</param-name>
 		<param-value>https://www.searchblox.com</param-value>
 </init-param>

or to allow multiple domains, edit as shown below separated by space between the domain values:

<init-param>
 	<param-name>cors.allowOrigin</param-name>
 	<param-value>https://localhost:8443 https://localhost:8446</param-value>
 </init-param>

Please save web.xml file and restart the SearchBlox service.

1412

What’s Next