public/index.php line 22

Open in your IDE?
  1. <?php
  2.   // respond to preflights
  3.   if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
  4.     // return only the headers and not the content
  5.     // only allow CORS if we're doing a GET - i.e. no saving for now.
  6.     if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']) && $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'] == 'POST') {
  7.       header('Access-Control-Allow-Origin: *');
  8.       header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
  9.       header('Access-Control-Allow-Headers: *');
  10.     }
  11.     exit;
  12.   } else {
  13.     header('Access-Control-Allow-Origin: *');
  14.     header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
  15.     header('Access-Control-Allow-Headers: Content-Type, x-requested-with');
  16.     header('Access-Control-Max-Age: 86400');
  17.   }
  18. use App\Kernel;
  19. require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
  20. return function (array $context) {
  21.     return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
  22. };