add(function ($request, $handler) { $response = $handler->handle($request); return $response ->withHeader('Access-Control-Allow-Origin', '*') ->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization') ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS'); }); $app->addRoutingMiddleware(); $app->addErrorMiddleware(true, true, true); // Options handler $app->options('/{routes:.+}', function ($request, $response) { return $response; }); // Init DB getDb(); // Register routes require __DIR__ . '/../src/routes.php'; $app->run();