Replies: 1 comment
-
|
This is a subtle but real-world Laravel deployment edge case This tells us the problem isn’t permissions or auth middleware — it’s autoloading or route caching behavior affected by optimize. If any class (for example, your BroadcastServiceProvider or a closure-based route) isn’t available when the caches are generated, Laravel may: Skip registering broadcast routes properly. Cache an invalid reference to the broadcast auth route. That’s why the /broadcasting/auth route ends up returning a 403 — the middleware stack or broadcaster guard fails to resolve correctly due to cached inconsistencies. composer dump-autoload --optimize --no-dev This command rebuilds the classmap and optimizes PSR-4 resolution. You can fix like this composer install --optimize-autoloader --no-dev |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
After deploying to our production server using Envoy, we encounter a 403 error on the
/broadcasting/authroute. The issue is specifically tied to thephp artisan optimizecommand. The issue is immediately resolved by runningcomposer dump-autoload --optimize --no-dev. Everything works correctly until the next deployment when the cycle repeats.Envoy.blade.php
Here is our deployment script for context:
Our current workaround is to add
composer dump-autoload --optimize --no-devto the Envoy script right after thephp artisan optimizecommand. This fixes the issue, but it feels redundant and we'd like to understand the root cause. Or is this normal behavior?Beta Was this translation helpful? Give feedback.
All reactions