`fly launch` for Laravel 11 fails
This line in the Dockerfile for Laravel stops fly launch running for the recently-released Laravel 11. Commenting out this line in the Dockerfile allows a Laravel 11 app to launch on fly
https://github.com/superfly/flyctl/blob/06ad6400fa94b1c355c2c61608d0d22471adfda8/scanner/templates/laravel/Dockerfile#L23
Laravel 11 changed where the config is for trusting all proxies. app/Http/Middleware/TrustProxies.php doesn't exist any more.
This is how to trust all proxies in Laravel 11: https://laravel.com/docs/11.x/requests#trusting-all-proxies
Adding the code below in bootstrap/app.php seems to be what to do but I am very very new to Laravel
->withMiddleware(function (Middleware $middleware) {
$middleware->trustProxies(at: '*');
})
Replace this line below in your dockerfile, from:
&& sed -i 's/protected \$proxies/protected \$proxies = "*"/g' app/Http/Middleware/TrustProxies.php \
to this:
&& sed -i '/->withMiddleware(function (Middleware \$middleware) {/a\
\$middleware->trustProxies(at: "*");' bootstrap/app.php \
Hello @edjw and @eznix86 !
Thank you for reporting this issue and suggesting a fix for this! Great job!
A new pre-release version of the flyctl command has been rolled out with the proper changes for setting Trusted Proxies for a Laravel 11 application. It will be included in the next major release for flyctl, but the pre-release is installable of course! Alternately, you can make use of the dockerfile-laravel package to generate Dockerfile supporting Laravel 11.