Skip to content

Commit

Permalink
Cors return origin
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Oct 6, 2024
1 parent 4f573e3 commit 8a2e908
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Core/Middleware/CorsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Psr\Http\Server\RequestHandlerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Windwalker\Core\Http\CorsHandler;
use Windwalker\Core\Manager\Logger;
use Windwalker\DI\Container;
use Windwalker\Http\Response\Response;
use Windwalker\Utilities\Options\OptionsResolverTrait;
Expand Down Expand Up @@ -102,7 +103,13 @@ public function getCorsHandler(ServerRequestInterface $request): CorsHandler
} else {
if (count($allows) === 1) {
// If only 1 allows, always send this as allow origin
$origin = $allows[0];

// If allow is not wildcards, set as the only 1 allow
if ($allows[0] !== '*') {
$origin = $allows[0];
}

// If allow is wildcards, keep the request origin
} elseif (count($allows) > 1) {
// Is has multiple allow, check origin in allow list
if (!in_array($origin, $allows, true)) {
Expand Down

0 comments on commit 8a2e908

Please sign in to comment.