Skip to content

Commit

Permalink
跨域问题
Browse files Browse the repository at this point in the history
  • Loading branch information
DDZH-DEV committed Jun 17, 2021
1 parent 97ea405 commit 57653ce
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/WebServer3.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public function onMessage($connection)
// p($_SERVER['HTTP_ORIGIN']);
//跨域问题
\Workerman\Protocols\Http::header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
\Workerman\Protocols\Http::header('Access-Control-Allow-Methods: GET,POST,PUT,OPTIONS');
\Workerman\Protocols\Http::header('Access-Control-Allow-Methods: *');
\Workerman\Protocols\Http::header('Access-Control-Allow-Credentials:true');
\Workerman\Protocols\Http::header('Access-Control-Allow-Origin:'.\Config::$http['cross_url']);
\Workerman\Protocols\Http::header('Access-Control-Allow-Origin:'.(isset($_SERVER['HTTP_ORIGIN'])? $_SERVER['HTTP_ORIGIN']: \Config::$http['cross_url']));

ob_start();

Expand Down
2 changes: 1 addition & 1 deletion core/WebServer4.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function __construct($socket_name = '', array $context_option = array())
'Access-Control-Allow-Credentials'=>'true',
'Access-Control-Allow-Methods'=>'GET, POST, PUT, OPTIONS',
'Access-Control-Allow-Headers'=>'*',
'Access-Control-Allow-Origin'=>\Config::$http['cross_url']
'Access-Control-Allow-Origin'=>(isset($_SERVER['HTTP_ORIGIN'])? $_SERVER['HTTP_ORIGIN']: \Config::$http['cross_url'])
];


Expand Down
2 changes: 1 addition & 1 deletion core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ function console($message,$type='info'){
function staticFix($url,$default_url=''){
$url=$url?$url:$default_url;
$cdn_url=\think\facade\Cache::get('db_cdn_url')?\think\facade\Cache::get('db_cdn_url'):Config::$http['cdn_url'];
return ($url && strpos($url,'http')===false)?$cdn_url.$url:($url?$url:$cdn_url.'/default-image.jpg');
return ($url && strpos($url,'http')===false)?$cdn_url.$url:$url;
}


Expand Down

0 comments on commit 57653ce

Please sign in to comment.