1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 16:40:05 +01:00

if http and https both exist, priotize http

This commit is contained in:
Afjalur Rahman Rana
2023-12-05 11:41:25 +00:00
parent ec7046f3a7
commit cd099f650f
2 changed files with 34 additions and 9 deletions

View File

@@ -55,17 +55,29 @@ public function currentTunnelUrl(string $domain = null): string
*/
public function findHttpTunnelUrl(array $tunnels, string $domain): ?string
{
$httpTunnel = null;
$httpsTunnel = null;
// If there are active tunnels on the Ngrok instance we will spin through them and
// find the one responding on HTTP. Each tunnel has an HTTP and a HTTPS address
// if no HTTP tunnel is found we will return the HTTPS tunnel as a fallback.
// Iterate through tunnels to find both HTTP and HTTPS tunnels
foreach ($tunnels as $tunnel) {
if (($tunnel->proto === 'http' || $tunnel->proto === 'https') && stripos($tunnel->config->addr, $domain)) {
return $tunnel->public_url;
if (stripos($tunnel->config->addr, $domain)) {
if ($tunnel->proto === 'http') {
$httpTunnel = $tunnel->public_url;
} elseif ($tunnel->proto === 'https') {
$httpsTunnel = $tunnel->public_url;
}
}
}
return null;
// Return HTTP tunnel if available, otherwise return HTTPS tunnel
return $httpTunnel ?? $httpsTunnel;
}
/**
* Set the Ngrok auth token.
*/