close

[Solved] Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL

Today I am facing the following error Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL in Laravel. We are going to Learn about All Possible Solutions So Lets Get Start with This Article.

How Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL Error Occurs ?

I am facing the following error.

  Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL

How To Solve Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL Error ?

  1. How To Solve Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL Error?

    To Solve Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL Error Here Is Official Statement By Laravel That If you are upgrading your Laravel 8 project to Laravel 9 by importing your existing application code into a totally new Laravel 9 application skeleton, you may need to update your application’s “trusted proxy” middleware.

  2. Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL

    To Solve Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL Error Here Is Official Statement By Laravel That If you are upgrading your Laravel 8 project to Laravel 9 by importing your existing application code into a totally new Laravel 9 application skeleton, you may need to update your application’s “trusted proxy” middleware.

Solution 1: Official Statement

Here Is Official Statement By Laravel That If you are upgrading your Laravel 8 project to Laravel 9 by importing your existing application code into a totally new Laravel 9 application skeleton, you may need to update your application’s “trusted proxy” middleware.

Within your app/Http/Middleware/TrustProxies.php file, update use Fideloper\Proxy\TrustProxies as Middleware to use Illuminate\Http\Middleware\TrustProxies as Middleware.

Next, within app/Http/Middleware/TrustProxies.php, you should update the $headers property definition:

// Before...protected $headers = Request::HEADER_X_FORWARDED_ALL; // After...protected $headers =    Request::HEADER_X_FORWARDED_FOR |    Request::HEADER_X_FORWARDED_HOST |    Request::HEADER_X_FORWARDED_PORT |    Request::HEADER_X_FORWARDED_PROTO |    Request::HEADER_X_FORWARDED_AWS_ELB;

Finally, you can remove the fideloper/proxy Composer dependency from your application:

composer remove fideloper/proxy

You can Read at Here.

Summary

It’s all About this error. Hope We solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

10 thoughts on “[Solved] Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL”

Leave a Comment