title: Why I am getting XMLHttpRequest cannot load - Preflight response is not successful Error with Delete method only?
body: <p>PHP resource file:</p>
  
  <pre><code>&lt;?php
  header("Access-Control-Allow-Origin: *");
  header("Content-Type: application/json; charset=UTF-8");
  header("Access-Control-Allow-Methods: POST, DELETE, OPTIONS, GET, PUT");
  header("Access-Control-Max-Age: 3600");
  header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
  
  require_once ("center_service.php");
  
  $data = json_decode(file_get_contents("php://input"));
  $method = $_SERVER['REQUEST_METHOD'];
  
  if (!isset($routes[2])) {
      $sql = "SELECT * FROM centers;";
      Center::readCenter($sql);
  } else if (isset($routes[2]) &amp;&amp; is_numeric($routes[2]) &amp;&amp; $method === "GET") {
      $sql = "SELECT * FROM centers WHERE id='$routes[2]';";
      Center::readCenter($sql);
  } else if (isset($routes[2]) &amp;&amp; is_numeric($routes[2]) &amp;&amp; $method === "DELETE") {
      Center::deleteCenter($routes[2]);
  }
  else {
      header('HTTP/1.0 404 Not Found');
      require '404.php';
  }
  </code></pre>
  
  <p>Angular service file:</p>
  
  <pre><code>readonly ROOT_URL = 'http://localhost/ecdweb/api/index.php';
  
  getCenters(): Observable&lt;Center[]&gt; {
    return this.http.get&lt;Center[]&gt;(this.ROOT_URL + '/centers');
  }
  deleteCenter(id: number): Observable&lt;{}&gt; {
    return this.http.delete(this.ROOT_URL + '/centers/' + id);
  }
  </code></pre>
  
  <p>The get method is working and return results but it doesn't work with delete method. If it's because of CORS, then why the get method is working?</p>
  
  <p>Console Log:
  <a href="https://i.stack.imgur.com/6l5SB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6l5SB.png" alt="enter image description here"></a></p>
  
  <p>Network:
  <a href="https://i.stack.imgur.com/VmKS1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VmKS1.png" alt="enter image description here"></a></p>
  
  <p>Related Questions:</p>
  
  <p><a href="https://stackoverflow.com/questions/47839947/xmlhttprequest-cannot-load-file-preflight-response-is-not-successful-er">“XMLHttpRequest cannot load file:///… Preflight response is not successful” error</a></p>
  
  <p><a href="https://stackoverflow.com/questions/40359565/preflight-response-is-not-successful">Preflight response is not successful</a></p>
  
  <p><a href="https://stackoverflow.com/questions/46719354/express-server-and-axios-cors-preflight-response-is-not-successful">Express server and Axios CORS Preflight response is not successful</a></p>