Fermin Perdomo

Senior Full Stack Engineer | PHP | JavaScript

If you are using a mail service provider like SendGrid, it can create a proxy that may cause issues when you try to validate emails, for example.

To fix this, go to your bootstrap app file and add this line to the middleware:

$middleware->trustProxies(at: '*');

Then it should look like this:

// bootstrap/app.php 
<?php 

use Illuminate\Foundation\Application; 
use Illuminate\Foundation\Configuration\Exceptions; 
use Illuminate\Foundation\Configuration\Middleware; 

return Application::configure(basePath: dirname(__DIR__)) 
    ->withRouting( 
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php', health: '/up', 
    ) 
    ->withMiddleware(function (Middleware $middleware) { 
        $middleware->trustProxies(at: '*'); 
    }) 
    ->withExceptions(function (Exceptions $exceptions) { // 
    })
    ->create();