Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: Since symfony/http-foundation 5.2: The "HEADER_X_FORWARDED_ALL" constant is deprecated

Tags:

php

laravel

After upgrading to PHP8 and one day later adding Mailcoach I'm getting the following error:

Since symfony/http-foundation 5.2: The "HEADER_X_FORWARDED_ALL" constant is deprecated, use either "HEADER_X_FORWARDED_FOR | HEADER_X_FORWARDED_HOST | HEADER_X_FORWARDED_PORT | HEADER_X_FORWARDED_PROTO" or "HEADER_X_FORWARDED_AWS_ELB" or "HEADER_X_FORWARDED_TRAEFIK" constants instead.

composer update runs without any errors.

Searching for this doesn't give me any results, especially not related to Laravel. There must be something that I'm missing.

The stack trace starts in Illuminate\Foundation\Http\Kernel->handle(...) and indicates it happens at $request = Request::capture().

My knowledge of all this is too limited to know what to look for or how to fix it.

like image 628
eskimo Avatar asked Sep 01 '25 17:09

eskimo


1 Answers

This also occurred to me because I have an SSL Filter set as a middleware in my Laravel application and because it uses HEADER_X_FORWARDED_ALL and that header was deprecated in the newer version of symfony, I received the same warnings as you. To correct it, I did exactly what the error message suggests and changed my request to HEADER_X_FORWARDED_FOR which solved the problem.

In reading the code here: https://github.com/spatie/Mailcoach/tree/main/app/Http/Middleware

it appears that MailCoach is also written with the Laravel Framework and that it recently updated the code to correct the issue. You can see the reference on the TrustProxies Middleware. I'd upgrade your instance of Mailcoach however you installed it to address the issue, or update the deprecated header.

like image 121
Dom DaFonte Avatar answered Sep 04 '25 08:09

Dom DaFonte