Skip to content

Commit 42e5f8a

Browse files
committed
CORS headers for auth
1 parent bd2dcdf commit 42e5f8a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

api.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,21 +2292,20 @@ protected function swagger($settings) {
22922292
}
22932293

22942294
protected function allowOrigin($origin,$allowOrigins) {
2295-
if ($allowOrigins=='*') {
2296-
header('Access-Control-Allow-Origin: *');
2297-
} else {
2298-
if ($origin) foreach (explode(',',$allowOrigins) as $o) {
2299-
if (preg_match('/^'.str_replace('\*','.*',preg_quote(strtolower(trim($o)))).'$/',$origin)) {
2300-
header('Access-Control-Allow-Origin: '.$origin);
2301-
break;
2302-
}
2295+
if ($origin) foreach (explode(',',$allowOrigins) as $o) {
2296+
if (preg_match('/^'.str_replace('\*','.*',preg_quote(strtolower(trim($o)))).'$/',$origin)) {
2297+
header('Access-Control-Allow-Origin: '.$origin);
2298+
break;
23032299
}
2300+
} else {
2301+
header('Access-Control-Allow-Origin: *');
23042302
}
23052303
}
23062304

23072305
public function executeCommand() {
23082306
if (isset($_SERVER['REQUEST_METHOD'])) {
23092307
$this->allowOrigin($this->settings['origin'],$this->settings['allow_origin']);
2308+
header('Access-Control-Allow-Credentials: true');
23102309
}
23112310
if (!$this->settings['request']) {
23122311
$this->swagger($this->settings);

0 commit comments

Comments
 (0)