Skip to content

Commit

Permalink
modify CORS
Browse files Browse the repository at this point in the history
add CORS for all requests as listener
  • Loading branch information
labudzinski committed Jun 13, 2024
1 parent bc9cd37 commit 354211d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/EventListener/CorsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public function onKernelResponse(ResponseEvent $event): void
}
if($request->headers->has('Access-Control-Allow-Headers')) {
$crossOriginHeaders['Access-Control-Allow-Headers'][] = $request->headers->get('Access-Control-Allow-Headers');
$crossOriginHeaders['Access-Control-Allow-Headers'] = implode(',', $crossOriginHeaders['Access-Control-Allow-Headers']);
}
if($request->headers->has('Access-Control-Request-Method')) {
$crossOriginHeaders['Access-Control-Allow-Methods'][] = $request->headers->get('Access-Control-Request-Method');
$crossOriginHeaders['Access-Control-Allow-Methods'] = implode(',', $crossOriginHeaders['Access-Control-Allow-Methods']);
}

$event->getResponse()->headers->add($crossOriginHeaders);
Expand Down

0 comments on commit 354211d

Please sign in to comment.