Download the PHP package ozee31/cakephp-cors without Composer
On this page you can find all versions of the php package ozee31/cakephp-cors. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ozee31/cakephp-cors
More information about ozee31/cakephp-cors
Files in ozee31/cakephp-cors
Package cakephp-cors
Short Description A CakePHP (3.3.x) plugin for activate cors domain in your application
License
Informations about the package cakephp-cors
cakephp-cors
A CakePHP (4+) plugin for activate cors domain in your application with Middleware.
For cake 3.3+ use branch cake-3
Requirements
- PHP version 7.2 or higher
- CakePhp 4.0 or higher
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
Quick Start
Loading the Plugin
By default the plugin authorize cors for all origins, all methods and all headers and caches all for one day.
Configuration
Default configuration
Change config
In app.php
add :
AllowOrigin (Access-Control-Allow-Origin)
A returned resource may have one Access-Control-Allow-Origin header, with the following syntax:
AllowCredentials (Access-Control-Allow-Credentials)
The Access-Control-Allow-Credentials header Indicates whether or not the response to the request can be exposed when the credentials flag is true. When used as part of a response to a preflight request, this indicates whether or not the actual request can be made using credentials. Note that simple GET requests are not preflighted, and so if a request is made for a resource with credentials, if this header is not returned with the resource, the response is ignored by the browser and not returned to web content.
AllowMethods (Access-Control-Allow-Methods)
AllowHeaders (Access-Control-Allow-Headers)
The Access-Control-Allow-Headers header is used in response to a preflight request to indicate which HTTP headers can be used when making the actual request.
ExposeHeaders (Access-Control-Expose-Headers)
The Access-Control-Expose-Headers header lets a server whitelist headers that browsers are allowed to access. For example:
MaxAge (Access-Control-Max-Age)
The Access-Control-Max-Age header indicates how long the results of a preflight request can be cached. For an example of a preflight request, see the above examples.
exceptionRenderer
This option overload default exceptionRenderer
in app.php
.
By default this class extends from Error.exceptionRenderer
to add Cors Headers
If you don't want to overload exceptionRenderer, You must write
All versions of cakephp-cors with dependencies
cakephp/cakephp Version ^4.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0