How to enable CORS on Tomcat for WASP (uimapi)
search cancel

How to enable CORS on Tomcat for WASP (uimapi)

book

Article ID: 187756

calendar_today

Updated On:

Products

DX Unified Infrastructure Management (Nimsoft / UIM) CA Unified Infrastructure Management On-Premise (Nimsoft / UIM) CA Unified Infrastructure Management SaaS (Nimsoft / UIM)

Issue/Introduction

We need to be able to enable CORS on the UIM webapi portlet. 
 
 

Environment

  • Release: 9.2.0
  • Component: UIM - NISAPI_WASP

Resolution

How to enable CORS in UIMAPI

Open web.xml file ~\Nimsoft\probes\service\wasp\webapps\uimapi\WEB-INF folder

Add below filter before “Front Door Filter” 

Restart the WASP.

 

<filter>
  <filter-name>CorsFilter</filter-name>
  <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
  <init-param>
    <param-name>cors.allowed.origins</param-name>
    <param-value>*</param-value> <!--  add allowed origins separated by comma eg: http://www.broadcom.net -->
  </init-param>
  <init-param>
    <param-name>cors.allowed.methods</param-name>
    <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
  </init-param>
  <init-param>
    <param-name>cors.allowed.headers</param-name>
    <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
  </init-param>
  <init-param>
    <param-name>cors.exposed.headers</param-name>
    <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
  </init-param>
  </filter>
<filter-mapping>
  <filter-name>CorsFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

Additional Information

It has been found in UIM 20.4 if the uimapi isn't updated, that having CORS disabled can prevent MCS profiles from being edited.  An "unknown error" is displayed stating to contact support.  By enabling CORS, the issue can be resolved.

Of course, updating uimapi will also resolve the issue.