Skip to main content Skip to complementary content

How to enable cross-origin resource sharing in MDM

Availability-noteDeprecated
The following introduce how to enable the cross-origin resource sharing support in MDM before consuming MDM REST resources.

Procedure

  1. Stop your Tomcat server.
  2. Browse to the file <TomcatPath>/webapps/talendmdm/WEB-INF/web.xml and open it.
  3. Add the following web application filter:
    <!-- CORS for development only -->
    <filter>
       <filter-name>CorsFilter</filter-name>
       <filter-class>com.amalto.core.util.CorsFilter</filter-class>
       <init-param>
          <param-name>allowed-origin</param-name>
          <param-value>YOUR WEB APP URL</param-value>
       </init-param>
    </filter>
    <filter-mapping>
       <filter-name>CorsFilter</filter-name>
       <url-pattern>/services/rest/*</url-pattern>
    </filter-mapping>

    In the filter, "YOUR WEB APP URL" indicates the base URL of your web application as displayed in your web browser, for example, http://192.168.174.170:3000.

    Because MDM REST services require authentication, this URL is mandatory and cannot use a wildcard (*).

  4. Restart the Tomcat server.
  5. Verify that the cross-origin resource sharing support is enabled successfully.
    You can try to access an MDM resource from a web browser with developer tools and check that the following HTTP headers are sent back in the response body:
    Access-Control-Allow-Credentials: true
    
     Access-Control-Allow-Headers: x-requested-with, Authorization, Content-Type
    
     Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT, PATCH
    
     Access-Control-Allow-Origin: YOUR WEB APP URL
    
     Access-Control-Max-Age: 3600

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!