Skip to content

Instantly share code, notes, and snippets.

@elnur
Last active December 15, 2015 18:49
Show Gist options
  • Save elnur/5306306 to your computer and use it in GitHub Desktop.
Save elnur/5306306 to your computer and use it in GitHub Desktop.
<?php
namespace Elnur\Listener;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use JMS\DiExtraBundle\Annotation\Service;
use JMS\DiExtraBundle\Annotation\Observe;
/**
* @Service
*/
class CorsListener
{
/**
* @Observe("kernel.response")
*/
public function onResponse(FilterResponseEvent $event)
{
$event->getResponse()->headers->add([
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => '*',
'Access-Control-Allow-Headers' => 'Authorization, X-Requested-With',
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment