From e72bf51c38fb08bdabae8698e6b601129f0c73f6 Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Sun, 14 Jun 2026 09:31:00 -0300 Subject: [PATCH] Make webhook host configurable via WEBHOOK_URL (sendkit-style domain group) --- .env.example | 4 ++++ config/app.php | 15 ++++++++++++++- docker/.env.docker.example | 4 ++++ routes/webhook.php | 6 +++++- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index dd9e2b17..dc13c3bb 100644 --- a/.env.example +++ b/.env.example @@ -4,6 +4,10 @@ APP_KEY= APP_DEBUG=true APP_URL=http://localhost +# Public base URL inbound webhooks (e.g. Telegram) are registered on. +# Defaults to APP_URL; set a tunnel URL (e.g. ngrok) for local development. +WEBHOOK_URL= + # Self-hosted mode (skips payment requirements) SELF_HOSTED=true diff --git a/config/app.php b/config/app.php index 997df9a8..e8080f34 100644 --- a/config/app.php +++ b/config/app.php @@ -54,7 +54,20 @@ | */ - 'url' => env('APP_URL', 'https://trypost.it'), + 'url' => env('APP_URL', 'https://app.trypost.it'), + + /* + |-------------------------------------------------------------------------- + | Webhook URL + |-------------------------------------------------------------------------- + | + | Public base URL that inbound provider webhooks (e.g. Telegram) are + | registered on. Defaults to the app URL; override it (for example with a + | tunnel like ngrok) when the app URL isn't reachable from the internet. + | + */ + + 'webhook_url' => env('WEBHOOK_URL', env('APP_URL', 'https://app.trypost.it')), /* |-------------------------------------------------------------------------- diff --git a/docker/.env.docker.example b/docker/.env.docker.example index 706b63df..0c31fd1a 100644 --- a/docker/.env.docker.example +++ b/docker/.env.docker.example @@ -4,6 +4,10 @@ APP_KEY= APP_DEBUG=true APP_URL=http://localhost:8000 +# Public base URL inbound webhooks (e.g. Telegram) are registered on. +# Defaults to APP_URL; set a tunnel URL (e.g. ngrok) for local development. +WEBHOOK_URL= + # Self-hosted mode (skips payment requirements) SELF_HOSTED=true diff --git a/routes/webhook.php b/routes/webhook.php index ecd2fee8..0f0c5d2b 100644 --- a/routes/webhook.php +++ b/routes/webhook.php @@ -5,4 +5,8 @@ use App\Http\Controllers\Webhooks\TelegramWebhookController; use Illuminate\Support\Facades\Route; -Route::post('telegram/webhook', [TelegramWebhookController::class, 'handle'])->name('telegram.webhook'); +Route::group([ + 'domain' => parse_url(config('app.webhook_url'), PHP_URL_HOST) ?: config('app.webhook_url'), +], function () { + Route::post('telegram/webhook', [TelegramWebhookController::class, 'handle'])->name('telegram.webhook'); +});