Final Class Yiisoft\Yii\Middleware\CorsAllowAll
| Inheritance | Yiisoft\Yii\Middleware\CorsAllowAll |
|---|---|
| Implements | Psr\Http\Server\MiddlewareInterface |
| Deprecated since version | Use `CorsAllowAllMiddleware` from `yiisoft/http-middleware` package instead. |
Adds Cross-Origin Resource Sharing (CORS) headers allowing everything to the response.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| process() | Yiisoft\Yii\Middleware\CorsAllowAll |
Method Details
| public \Psr\Http\Message\ResponseInterface process ( \Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler ) | ||
| $request | \Psr\Http\Message\ServerRequestInterface | |
| $handler | \Psr\Http\Server\RequestHandlerInterface | |
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);
return $response
->withHeader(Header::ALLOW, '*')
->withHeader(Header::VARY, 'Origin')
->withHeader(Header::ACCESS_CONTROL_ALLOW_ORIGIN, '*')
->withHeader(Header::ACCESS_CONTROL_ALLOW_METHODS, 'GET,OPTIONS,HEAD,POST,PUT,PATCH,DELETE')
->withHeader(Header::ACCESS_CONTROL_ALLOW_HEADERS, '*')
->withHeader(Header::ACCESS_CONTROL_EXPOSE_HEADERS, '*')
->withHeader(Header::ACCESS_CONTROL_ALLOW_CREDENTIALS, 'true')
->withHeader(Header::ACCESS_CONTROL_MAX_AGE, '86400');
}
Signup or Login in order to comment.