feat: Config option to set default protocol to https (#110)

* feat: Config option to set default protocol to https

* style: Fix for StyleCI
This commit is contained in:
Dennis Koch
2021-03-31 07:41:34 +02:00
committed by GitHub
parent cca03ab8b2
commit 8d5a4410f7
2 changed files with 20 additions and 3 deletions

View File

@@ -59,14 +59,19 @@ class ShareCurrentWorkingDirectoryCommand extends ShareCommand
return str_replace('.', '-', basename($projectPath));
}
protected function prepareSharedHost($host): string
protected function detectProtocol($host): string
{
$certificateFile = ($_SERVER['HOME'] ?? $_SERVER['USERPROFILE']).DIRECTORY_SEPARATOR.'.config'.DIRECTORY_SEPARATOR.'valet'.DIRECTORY_SEPARATOR.'Certificates'.DIRECTORY_SEPARATOR.$host.'.crt';
if (file_exists($certificateFile)) {
return 'https://'.$host;
return 'https://';
}
return $host;
return config('expose.default_https', false) ? 'https://' : 'http://';
}
protected function prepareSharedHost($host): string
{
return $this->detectProtocol($host).$host;
}
}

View File

@@ -55,6 +55,18 @@ return [
*/
'default_tld' => 'test',
/*
|--------------------------------------------------------------------------
| Default HTTPS
|--------------------------------------------------------------------------
|
| Whether to use HTTPS as a default when sharing your local sites. Expose
| will try to look up the protocol if you are using Laravel Valet
| automatically. Otherwise you can specify it here manually.
|
*/
'default_https' => false,
/*
|--------------------------------------------------------------------------
| Maximum Logged Requests