container = $container; } public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $response = Context::get(ResponseInterface::class); $response = $response->withHeader('Access-Control-Allow-Origin', '*') ->withHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, DELETE, PUT, PATCH') ->withHeader( 'Access-Control-Allow-Headers', 'SIG,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,'. 'Cache-Control,Content-Type,Accept-Language,Origin,Accept-Encoding,'. 'Authorization,Access-Control-Allow-Origin' ); Context::set(ResponseInterface::class, $response); if ($request->getMethod() == 'OPTIONS') { return $response; } return $handler->handle($request); } }