Angular 2 Rest API for Openmrs

One thing more which version of apache tomcat used in standalone version 2.5. Because I think CORS is supported in Tomcat version 7.0.41 or above?

I am calling REST API Daniel these are not related to my query.I want to ask which version of tomcat is used in standalone 2.5 version. I am trying to add CORS to tomcat/config/web.xml but it’s not working.

Tomcat 7.0.50 is used by the standalone.

Please try this instead (not rely on defaults):

<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>
  </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>
  <init-param>
    <param-name>cors.support.credentials</param-name>
    <param-value>true</param-value>
  </init-param>
  <init-param>
    <param-name>cors.preflight.maxage</param-name>
    <param-value>10</param-value>
  </init-param>
</filter>
<filter-mapping>
  <filter-name>CorsFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

I tried this also but same error occured. Failed to load resource: the server responded with a status of 403 (Forbidden) products:1 XMLHttpRequest cannot load http://localhost:8081/openmrs-standalone/ws/rest/v1/concept. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:3000’ is therefore not allowed access. The response had HTTP status code 403.

Note:When I try to run with chrome extension CORS.It worked for me without changing the tomcat/config/web.xml.But when I changed the web.xml file.It also does not worked then.

Please try:

and:

Same Error.I try every options available on stack overflow but none of one work for me.

I’d try with a different cors filter, e.g. http://software.dzhuvinov.com/cors-filter-installation.html

I used that one in the past and it worked. The drawback is that you need to add its jar to the server. It’s all explained on that page.

This worked for me today. Thanks @raff