A builder object that assists in defining Cross Origin Request related headers.
Each of the methods in this object provide a fluent interface. Once you've set all the headers you want to use, the build()
method can be used to return a modified Response.
It is most convenient to get this object via Request::cors()
.
$_headers
protected array
$_isSsl
protected boolean
$_origin
protected string
$_response
protected Cake\Network\Response
__construct( Cake\Network\Response $response , string $origin , boolean $isSsl false )
Constructor.
$response
$origin
$isSsl
optional false _normalizeDomains( array $domains )
Normalize the origin to regular expressions and put in an array format
$domains
allowCredentials( )
Enable cookies to be sent in CORS requests.
allowHeaders( array $headers )
Whitelist headers that can be sent in CORS requests.
$headers
allowMethods( array $methods )
Set the list of allowed HTTP Methods.
$methods
allowOrigin( string|array $domain )
Set the list of allowed domains.
Accepts a string or an array of domains that have CORS enabled. You can use *.example.com
wildcards to accept subdomains, or *
to allow all domains
$domain
build( )
Apply the queued headers to the response.
If the builder has no Origin, or if there are no allowed domains, or if the allowed domains do not match the Origin header no headers will be applied.
exposeHeaders( array $headers )
Define the headers a client library/browser can expose to scripting
$headers
maxAge( integer $age )
Define the max-age preflight OPTIONS requests are valid for.
$age
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.4/class-Cake.Network.CorsBuilder.html