Skip to content

Commit 03157d5

Browse files
committed
Add CORS to OPTIONS
1 parent 445a2ae commit 03157d5

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Cors.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,19 @@ public function __construct(HttpKernelInterface $app, array $options = array())
4545

4646
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
4747
{
48-
if ($request->getMethod() === 'OPTIONS') {
49-
if ($this->cors->isPreflightRequest($request)) {
50-
$response = $this->cors->handlePreflightRequest($request);
51-
} else {
52-
$response = $this->app->handle($request, $type, $catch);
53-
}
54-
48+
if ($this->cors->isPreflightRequest($request)) {
49+
$response = $this->cors->handlePreflightRequest($request);
5550
$this->cors->varyHeader($response, 'Access-Control-Request-Method');
5651

5752
return $response;
5853
}
5954

6055
$response = $this->app->handle($request, $type, $catch);
6156

57+
if ($request->getMethod() === 'OPTIONS') {
58+
$this->cors->varyHeader($response, 'Access-Control-Request-Method');
59+
}
60+
6261
return $this->cors->addActualRequestHeaders($response, $request);
6362
}
6463
}

0 commit comments

Comments
 (0)