Laravel Version: Laravel 5.4.30
I am having an issue whereby my production code is hosted on AWS Elastic Beanstalk behind a load balancer served via HTTPS. When using the built in auth trait and make:auth controllers to validate user login, upon login form submission the user is being redirected to:
http://application-url rather than https://application-url/dashboard
In the LoginController it should route after login to the /dashboard
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/dashboard';
On the login controller when I view the source of the blade login template I can see the form submits to the correct URL, https://application-url/login.
I am using the following to force HTTPS in the AppServiceProvider.php file:
if (!\App::environment('local')) {
\URL::forceScheme('https');
}
Once the user has 'authenticated' and the browser cannot resolve the http version, upon clicking the back button on they are sent to the correct /dashboard route.
Is there another location upon login form submission that I am missing?
Just in case someone still bumps into this, the Documentation says:
It is basically caused by a request passing an unknown layer in it's way to your instance.
Solution for AWS
Modify the TrustProxies middleware included in App\Http\Middleware: