Skip to content

Commit

Permalink
fix(core) Update cors config
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAnyx committed Dec 2, 2024
1 parent 9f56e38 commit 67db456
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
14 changes: 5 additions & 9 deletions config/packages/nelmio_cors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ nelmio_cors:
defaults:
origin_regex: false
allow_origin: ["%env(CORS_ALLOW_ORIGIN)%"]
allow_methods: ["GET", "POST", "PUT", "PATCH", "DELETE"]
allow_headers: ["Authorization", "Accept"]
max_age: 3600
allow_methods: ["GET", "OPTIONS", "POST", "PUT", "PATCH", "DELETE"]
allow_headers: ["Content-Type", "Authorization", "Accept"]
expose_headers: ["Link"]
max_age: 0
paths:
"^/":
origin_regex: false
allow_origin: ["%env(CORS_ALLOW_ORIGIN)%"]
allow_methods: ["GET", "POST", "PUT", "PATCH", "DELETE"]
allow_headers: ["Authorization", "Accept"]
max_age: 3600
"^/": ~
9 changes: 4 additions & 5 deletions src/EventSubscriber/ResponseSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ class ResponseSubscriber implements EventSubscriberInterface
{
public function onKernelResponse(ResponseEvent $event): void
{
$initialRequest = $event->getRequest();

// if (!\in_array($initialRequest->getMethod(), ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])) {
// return;
// }
if (!$event->isMainRequest()) {
return;
}

$initialRequest = $event->getRequest();
$initialResponse = $event->getResponse();

// Enabled only for project routes, not symfony routes like the profiler
Expand Down

0 comments on commit 67db456

Please sign in to comment.