title: No 'Access-Control-Allow-Origin' header is present on the requested resource | Firebase Cloud Firestore - Java - Ionic
body: <p>I'm developing an application and I'm using Ionic (Angular) for client side, java (JAX-RS) as backend and Firebase Cloud Firestore for persistence. Maybe this stack is weird but I'm new in create real applications and Firebase caughy my attention.</p>
  <p>I want to save data in Firebase Cloud Firestore using Ionic with an REST API, I can do this with tools like postman, but i can't with Ionic, I'm getting an error <em>No 'Access-Control-Allow-Origin' header is present on the requested resource</em>. You will say to me that configure my server to allow requests but I do this already, I test my REST API without including the part of saving data in Firebase Cloud Firestore, and this work perfectly, I don't get that error. The problem only spends when I call a Firebase method.</p>
  <p><strong>Server Configuration</strong></p>
  <p>I add the following Java Class</p>
  <pre><code>package api;
  
  public class RestCorsFilter implements Filter {
  
      @Override
      public void destroy() {
          //enter code here
      }
  
      @Override
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
              throws IOException, ServletException {
  
          HttpServletResponse resp = (HttpServletResponse) response;
          resp.addHeader(&quot;Access-Control-Allow-Origin&quot;, &quot;*&quot;);
          resp.addHeader(&quot;Access-Control-Allow-Headers&quot;, &quot;*&quot;);
          resp.addHeader(&quot;Access-Control-Allow-Methods&quot;, &quot;*&quot;);
  
          chain.doFilter(request, resp);
  
      }
  
      @Override
      public void init(FilterConfig arg0) throws ServletException {
  
      }
  
  }
  </code></pre>
  <p>And then, I add this fragment in <code>web.xml</code></p>
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;RestCorsFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;api.RestCorsFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;RestCorsFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/api/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  <p>My application path:</p>
  <pre><code>@ApplicationPath(&quot;/api&quot;)
  </code></pre>