Last active
December 15, 2015 18:49
-
-
Save elnur/5306306 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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