Enable CORS on Tomcat 8.0.30
<p>Appreciate any help.</p>

<p>I'm facing the problem with the CORS on my newly deployed Tomcat 8.0.30. I keep getting the error below. I am using 127.0.0.1 as the API server address and 192.168.1.100 is the address of my HTTP server.</p>

<blockquote>
  <p>No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '_http://192.168.1.100:8999' is therefore not allowed access. The response had HTTP status code 403.</p>
</blockquote>

<p>Read through whole Tomcat documentation, added the cors filter under the tomcat web.xml, as well as the project web.xml, but nothing magic happens here, still getting the same error. Tried both minimal and advanced with init-param, same error.</p>

<p>I am using Spring 4 as my rest api framework. Any more configurations need to be done on the project coding part?</p>

<p>Here are the steps I've done so far:</p>

<ul>
<li>add cors filter under web.xml, mininal config according to documentation, not working</li>
<li>add cors filter under web.xml, full config, not working as well.</li>
<li>tried to use cors filter from <a href="http://software.dzhuvinov.com/cors-filter.html" rel="nofollow noreferrer">http://software.dzhuvinov.com/cors-filter.html</a>, still not working</li>
</ul>

<p>Any suggestions?</p>

<p><a href="https://i.stack.imgur.com/2JEj2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2JEj2.png" alt="network response"></a></p>

<hr>

<p>Add the web.xml configuration
I've tried to change cors.allowed.origins to *, to 127.0.0.1,192.168.1.100, all not working,
remove credentials and maxage</p>

<pre><code>&lt;filter&gt;
  &lt;filter-name&gt;CorsFilter&lt;/filter-name&gt;
  &lt;filter-class&gt;org.apache.catalina.filters.CorsFilter&lt;/filter-class&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;cors.allowed.origins&lt;/param-name&gt;
    &lt;param-value&gt;http://192.168.1.100&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;cors.allowed.methods&lt;/param-name&gt;
    &lt;param-value&gt;GET,POST,HEAD,OPTIONS,PUT&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;cors.allowed.headers&lt;/param-name&gt;
    &lt;param-value&gt;Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;cors.exposed.headers&lt;/param-name&gt;
    &lt;param-value&gt;Access-Control-Allow-Origin,Access-Control-Allow-Credentials&lt;/param-value&gt;
  &lt;/init-param&gt;
&lt;/filter&gt;
&lt;filter-mapping&gt;
  &lt;filter-name&gt;CorsFilter&lt;/filter-name&gt;
  &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;
</code></pre>

<hr>

<p>Suggested by Vishal, changing tomcat version from 8.0 to 8.5, still same issue</p>

<pre><code> XMLHttpRequest cannot load http://127.0.0.1:8080/leyutech-framework-gurunwanfeng/api/ad/getAdInfoByAdType.html?adType=0. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.1.100:8080' is therefore not allowed access. The response had HTTP status code 403.
</code></pre>