mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 08:30:07 +01:00
Valet fetch-share-url issue fix (#1285)
* valet fetch-share-url issue fix * StyleCI patch
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Valet;
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
class Ngrok
|
||||
@@ -23,17 +24,25 @@ public function currentTunnelUrl($domain = null)
|
||||
sleep(1);
|
||||
|
||||
foreach ($this->tunnelsEndpoints as $endpoint) {
|
||||
try {
|
||||
$response = retry(20, function () use ($endpoint, $domain) {
|
||||
$body = json_decode((new Client())->get($endpoint)->getBody());
|
||||
|
||||
if (isset($body->tunnels) && count($body->tunnels) > 0) {
|
||||
return $this->findHttpTunnelUrl($body->tunnels, $domain);
|
||||
if ($tunnelUrl = $this->findHttpTunnelUrl($body->tunnels, $domain)) {
|
||||
return $tunnelUrl;
|
||||
}
|
||||
}
|
||||
|
||||
throw new DomainException('Failed to retrieve tunnel URL.');
|
||||
}, 250);
|
||||
|
||||
if (! empty($response)) {
|
||||
return $response;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// Do nothing, suppress the exception to check the other port
|
||||
}
|
||||
}
|
||||
|
||||
throw new DomainException('Tunnel not established.');
|
||||
|
||||
Reference in New Issue
Block a user