title: CORS errors in PHP backend consumed by Reactjs
body: <p>When I make a POST request I get the error 
  <code>Access to XMLHttpRequest at 'http://localhost/vla-php/room/create.php' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.</code> 
  on the console.</p>
  
  <p>Using Postman works fine, however, trying to consume it from a React frontend results in the above error.</p>
  
  <p>I already have CORS enabled by setting access control to allow all origins (*)</p>
  
  <p><code>.htaccess</code> is an empty file. I doubt if that would be a hinderance.</p>
  
  <p>The PHP code looks like so;</p>
  
  <pre><code>&lt;?php
  // required headers
  header("Access-Control-Allow-Origin: *");
  header("Content-Type: application/json; charset=UTF-8");
  header("Access-Control-Allow-Methods: POST");
  header("Access-Control-Max-Age: 3600");
  header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
  
  // get database connection
  include_once '../config/database.php';
  
  // instantiate product object
  include_once '../objects/room.php';
  
  $database = new Database();
  $db = $database-&gt;getConnection();
  
  $room = new Room($db);
  
  // get posted data
  $data = json_decode(file_get_contents("php://input"));
  
  // make sure data is not empty
  if(
      !empty($data-&gt;name) &amp;&amp;
      !empty($data-&gt;category) &amp;&amp;
      !empty($data-&gt;type)
  ){
  
      // set product property values
      $room-&gt;name = $data-&gt;name;
      $room-&gt;category = $data-&gt;category;
      $room-&gt;type = $data-&gt;type;
  
      // create the product
  
      if($room-&gt;create()){
  
          // set response code - 201 created
          http_response_code(201);
  
          // tell the user
          echo json_encode(array("message" =&gt; "Room was created."));
      }
  
      // if unable to create the product, tell the user
      else{
  
          // set response code - 503 service unavailable
          http_response_code(503);
  
          // tell the user
          echo json_encode(array("message" =&gt; "Unable to create room."));
      }
  }
  
  // tell the user data is incomplete
  else{
  
      // set response code - 400 bad request
      http_response_code(400);
  
      // tell the user
      echo json_encode(array("message" =&gt; "Unable to create room. Data is incomplete."));
  }
  ?&gt;
  </code></pre>