mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 15:23:12 +08:00
Allow credentials to be enabled in CORS
This commit is contained in:
@@ -8,6 +8,7 @@ use Shlinkio\Shlink\Core\Config\EnvVars;
|
||||
|
||||
use function Shlinkio\Shlink\Core\ArrayUtils\contains;
|
||||
use function Shlinkio\Shlink\Core\splitByComma;
|
||||
use function strtolower;
|
||||
|
||||
final readonly class CorsOptions
|
||||
{
|
||||
@@ -21,9 +22,10 @@ final readonly class CorsOptions
|
||||
public bool $allowCredentials = false,
|
||||
public int $maxAge = 3600,
|
||||
) {
|
||||
$this->allowOrigins = $allowOrigins !== '*' && $allowOrigins !== self::ORIGIN_PATTERN
|
||||
? splitByComma($allowOrigins)
|
||||
: $allowOrigins;
|
||||
$lowerCaseAllowOrigins = strtolower($allowOrigins);
|
||||
$this->allowOrigins = contains($lowerCaseAllowOrigins, ['*', self::ORIGIN_PATTERN])
|
||||
? $lowerCaseAllowOrigins
|
||||
: splitByComma($lowerCaseAllowOrigins);
|
||||
}
|
||||
|
||||
public static function fromEnv(): self
|
||||
|
||||
Reference in New Issue
Block a user