fixed scheme

This commit is contained in:
Edward Yang 2022-09-20 17:19:45 +08:00 committed by Edward Yang
parent ae5c8f13ff
commit cccdf77800
2 changed files with 24 additions and 1 deletions

View File

@ -602,3 +602,25 @@ function is_mobile()
{
return (new \Jenssegers\Agent\Agent())->isMobile();
}
/**
* 当前访问协议是否为 https
*
* @return bool
*/
function is_secure()
{
if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
return true;
} elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https') {
return true;
} elseif (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') {
return true;
} elseif (isset($_SERVER['SERVER_PORT']) && intval($_SERVER['SERVER_PORT']) === 443) {
return true;
} elseif (isset($_SERVER['REQUEST_SCHEME']) && strtolower($_SERVER['REQUEST_SCHEME']) === 'https') {
return true;
}
return false;
}

View File

@ -94,7 +94,8 @@ class EnvironmentManager
{
$results = trans('installer::installer_messages.environment.success');
$appUrl = $_SERVER['REQUEST_SCHEME'] . "://";
$scheme = is_secure() ? 'https' : 'http';
$appUrl = $scheme . "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$appUrl .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"];
} else {