Laravel request() helper won't work when app is optimized.
strtolower(request()->header('Request-From')) == "portal" ? "auth:sanctum" : "api.auth";
I have a logic to check which middleware to use depending on a header Request-From value. This works perfectly when the app is not optimized. But when i run php artisan optimize, the ternary operator returns false giving me api:auth. Again when i run php artisan optimize:clear i have auth:sanctum.
PS: The request header was available when checked with telescope
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community