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:Jump to 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.
5 Replies
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
can you please drop the docs or attach the thread of the question so I can try implementing
see:
https://discord.com/channels/883083792112300104/1338103350977237046
I think octane runs similar.
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.
Solution
@toeknee Thank you, It worked after adding the
trustProxies
Middleware inbootstrap/app.php
.
More details in this blog: https://laravel-news.com/managing-proxy-trust-in-laravel-applicationsLaravel 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.