From 27573217850700261624c0060f7f9138099f8c91 Mon Sep 17 00:00:00 2001 From: Cathrine Vaage Date: Tue, 4 May 2021 14:53:56 +0200 Subject: [PATCH] Adds support for ngrok region --- src/NgrokProcessBuilder.php | 6 ++++++ src/NgrokServiceProvider.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/NgrokProcessBuilder.php b/src/NgrokProcessBuilder.php index 4d844a1..5745281 100644 --- a/src/NgrokProcessBuilder.php +++ b/src/NgrokProcessBuilder.php @@ -52,6 +52,12 @@ public function buildProcess(string $host = '', string $port = '80') : Process { $command = ['ngrok', 'http', '--log', 'stdout']; + $region = env('NGROK_REGION'); + + if ($region) { + $command[] = "-region={$region}"; + } + if ($host !== '') { $command[] = '--host-header'; $command[] = $host; diff --git a/src/NgrokServiceProvider.php b/src/NgrokServiceProvider.php index 966ff1b..c7965a5 100644 --- a/src/NgrokServiceProvider.php +++ b/src/NgrokServiceProvider.php @@ -115,6 +115,6 @@ private function extractOriginalHost(Request $request) : string */ private function isNgrokHost(string $host) : bool { - return preg_match('/^[a-z0-9]+\.ngrok\.io$/i', $host); + return preg_match('/^[a-z0-9]+(?:\.[a-z]{2})?\.ngrok\.io$/i', $host); } }