Skip to content

Commit

Permalink
πŸ”€ Merge pull request #2 from bluesn4rfer/dev
Browse files Browse the repository at this point in the history
Added check for HTTP_ORIGIN index (fix #1)
  • Loading branch information
mychidarko committed Jul 25, 2022
2 parents 5a0c77b + 03c6bd7 commit 10934a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Cors.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected static function configureOrigin()
if (static::isOriginAllowed($origin)) {
Headers::accessControl(
'Allow-Origin',
$_SERVER['HTTP_ORIGIN']
$_SERVER['HTTP_ORIGIN'] ?? $_SERVER['HTTP_HOST']
);
}

Expand Down Expand Up @@ -126,8 +126,8 @@ protected static function configureCredentials()

protected static function isOriginAllowed($allowedOrigin)
{
$origin = $_SERVER['HTTP_ORIGIN'];

$origin = $_SERVER['HTTP_ORIGIN'] ?? $_SERVER['HTTP_HOST'];
if (is_array($allowedOrigin)) {
for ($i = 0; $i < count($allowedOrigin); $i++) {
if (static::isOriginAllowed($allowedOrigin[$i])) {
Expand Down

0 comments on commit 10934a7

Please sign in to comment.