File Upload Fails with 401 After Switching to Octane

After switching to Laravel Octane, Livewire file uploads are failing with a 401 Unauthorized error. Everything worked fine before. I’ve tried changing the session to Redis, exempting the upload route from CSRF, setting SESSION_DOMAIN, verifying cookies and tokens are sent, and updating Livewire. Octane has been flushed and reloaded, but the issue persists. Any ideas on what could be causing this?
Solution:
@toeknee Thank you, It worked after adding the trustProxies Middleware inbootstrap/app.php. ```php ->withMiddleware(function (Middleware $middleware) { $middleware->trustProxies(...
Laravel News
Managing Proxy Trust in Laravel Applications - Laravel News
Learn how to configure Laravel's TrustProxies middleware for applications behind load balancers. Ensure proper HTTPS detection and client IP handling while maintaining security in various deployment environments.
Jump to solution
5 Replies
toeknee
toeknee2w ago
I think this is because of the proxy's and you need to allow the proxy in the laravel config, I am sure this was asked recently but about ngrok
Boa Hancock
Boa HancockOP2w ago
can you please drop the docs or attach the thread of the question so I can try implementing
Boa Hancock
Boa HancockOP2w ago
I’m using a reverse proxy in both cases. However, I encounter an error when running with Octane, not with the regular php artisan serve. php artisan serve works fine, but when I run php artisan octane:start with FrankenPHP, it throws an error.
No description
Solution
Boa Hancock
Boa Hancock2w ago
@toeknee Thank you, It worked after adding the trustProxies Middleware inbootstrap/app.php.
->withMiddleware(function (Middleware $middleware) {
$middleware->trustProxies(
at: '*',
headers: Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_PROTO
);
})
->withMiddleware(function (Middleware $middleware) {
$middleware->trustProxies(
at: '*',
headers: Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_PROTO
);
})
More details in this blog: https://laravel-news.com/managing-proxy-trust-in-laravel-applications
Laravel News
Managing Proxy Trust in Laravel Applications - Laravel News
Learn how to configure Laravel's TrustProxies middleware for applications behind load balancers. Ensure proper HTTPS detection and client IP handling while maintaining security in various deployment environments.

Did you find this page helpful?