title: Ionic - blocked by CORS policy: No 'Access-Control-Allow-Origin'
body: <p>I've created an Ionic app that connected to an API website where i have connected my website to CloudFlare for protection purposes, before i enabled the <strong>Under Attack Mode</strong> the requests where sent perfectly without any errors, but now it shows an error in console that saying:</p>
  
  <p><code>
  Access to XMLHttpRequest at 'https://mywebsite.org/api/mobile/news?pageSize=15&amp;currentPage=1&amp;language=undefined' from origin 'http://localhost:8100' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
  </code></p>
  
  <p>The back-end is a flask micro service and i am also enabling the cors roles,</p>
  
  <p><code>cors.init_app(app, resources={r"https://mywebsite.org/api/*": {"origins": "https://mywebsite.org"}})</code></p>
  
  <p>Every time i am sending a get request from the app, i am also adding a Access-Control-Allow-Origin to the headers:</p>
  
  <pre><code>let headers = new HttpHeaders({
      "Access-Control-Allow-Origin":"https://mywebsite.org/",
      "origin":"https://mywebsite.org/"
  });
  
  @Injectable({
      providedIn: 'root'
  })
  export class DataApiService {
  
      private apiUrl: string = 'https://mywebsite.org/api';
  
  
      constructor(
      private http: HttpClient,
      private translate: TranslateService
      ) { }
  
      // Get news
      apiRequest(url: string, params?:any){
  
      const apiUri = `${this.apiUrl+url}`;
  
      if(params){
          params.language = this.translate.getDefaultLang();
      }
  
      return this.http.get(apiUri, { headers: headers, params: params }).pipe(
          delay(
          500
          ),
          map(
          (res:any) =&gt; {
              return res
          }
          )
      )
      }
  }
  </code></pre>
  
  <p>Please any help.</p>