From 57dd8ee3780b5a9e1b79f7632d550212db83be9e Mon Sep 17 00:00:00 2001 From: Mekan1206 Date: Sun, 16 Aug 2026 17:18:16 +0500 Subject: [PATCH] Update BroadcastServiceProvider to include API versioning and enhanced middleware configuration. Revise Nginx configuration comments for clarity on broadcasting and websocket proxy setup. --- app/Providers/BroadcastServiceProvider.php | 5 +++++ nginx/reverb.conf | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 5add828..c4412fe 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -17,6 +17,11 @@ class BroadcastServiceProvider extends ServiceProvider { Broadcast::routes(['middleware' => ['auth:sanctum']]); + Broadcast::routes([ + 'prefix' => 'api/v1', + 'middleware' => ['api', 'api_token', 'auth:sanctum'], + ]); + Broadcast::routes([ 'prefix' => 'panel', 'middleware' => ['web', NovaAuthenticate::class, NovaAuthorize::class, EnsureChatOperator::class], diff --git a/nginx/reverb.conf b/nginx/reverb.conf index 794e208..6ee1c07 100644 --- a/nginx/reverb.conf +++ b/nginx/reverb.conf @@ -1,10 +1,18 @@ -# Laravel Reverb websocket proxy for mm.com.tm +# Laravel Reverb + broadcasting auth for mm.com.tm # -# Paste this location into the existing HTTPS server { } for mm.com.tm, -# BEFORE any frontend SPA catch-all. +# Paste into the existing HTTPS server { } for mm.com.tm. # -# Reverb (supervisor) stays on 127.0.0.1:8080. -# Browsers connect to wss://mm.com.tm/app/... +# 1) Laravel PHP prefixes MUST include `broadcasting`, otherwise +# POST /broadcasting/auth is caught by `location /` and proxied to +# the SPA on :4173 (404). Keep this in the same regex as api/panel: +# +# location ~ ^/(api|storage|panel|vendor|nova-api|nova-vendor|sanctum|nova|app-docs|broadcasting) { +# try_files $uri $uri/ /index.php?$query_string; +# } +# +# 2) Reverb (supervisor) stays on 127.0.0.1:8080. +# Browsers connect to wss://mm.com.tm/app/... +# Place `location /app` BEFORE the SPA `location /` catch-all. location /app { proxy_http_version 1.1;