из это артикул:
CorsListener.php
<?php
namespace MyCorp\MyBundle\Listener;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
class CorsListener
{
public function onKernelResponse(FilterResponseEvent $event)
{
$responseHeaders = $event->getResponse()->headers;
$responseHeaders->set('Access-Control-Allow-Headers', 'origin, content-type, accept');
$responseHeaders->set('Access-Control-Allow-Origin', '*');
$responseHeaders->set('Access-Control-Allow-Methods', 'POST, GET, PUT, DELETE, PATCH, OPTIONS');
}
}
services.yml
app.cors_listener:
class: MyCorp\MyBundle\Listener\CorsListener
tags:
- { name: kernel.event_listener, event: kernel.response, method: onKernelResponse }