I'm trying to connect to an API that was made in Java, but I always get the error when trying to connect (I want to feed a mobile application, done in JS / Cordova).
When I connect (via Browser) I get it, the API returns and everything works normal, but when I install the app on the mobile phone, error 401. I talked to several people, and it seems to be CORS error. The problem is that the API was not the one I developed, so I asked for the code that releases the CORS before coming here. and he gave it to me here.
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern> /* </url-pattern>
</filter-mapping>
Can anyone tell me if it's right? or what is the best way to do it?