Skip to content

sokil/CorsBundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CorsBundle

Handling CORS Requests

Total Downloads

Installation

Add composer dependency:

composer.phar require sokil/cors-bundle

Register bundle in your AppKernel:

<?php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Sokil\CorsBundle\CorsBundle(),
        );
    }
}

Configuration

Configure bundle in your /app/config/config.yml:

cors:
  allowedOrigins: # list of hosts, allowed to do CORS requests to your app. 
    - https://fb.com
    - https://google.com
  withCredentials: true # allow send cookies to your hosts between requests
  maxAge: 86400 # agte of prefligt request cache

Useage

Listener CorsRequestListener is listened to kernel events of requests and add headers if this is CORS request and CORS allowed for that host.