From 1b152a31c6df214a13d4c14ff8d9cdaddeaf1137 Mon Sep 17 00:00:00 2001 From: Jonathan Montgomery Date: Sat, 5 Feb 2022 17:12:58 -0400 Subject: [PATCH] Update laravel.md In order to get Laravel generating proper URLs, the TrustProxies middleware needs to be changed. --- docs/frameworks/laravel.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/frameworks/laravel.md b/docs/frameworks/laravel.md index 5d7984ef0..35d23df3e 100644 --- a/docs/frameworks/laravel.md +++ b/docs/frameworks/laravel.md @@ -141,6 +141,19 @@ uploading your assets to S3 automatically. For more details, see the [Websites section](/docs/websites.md) of this documentation and the official Lift documentation. +### Trusted proxies + +Because Laravel is executed through API Gateway, the Host header is set to the API Gateway host name. Helper functions +such as redirect() will incorrectly use this host name. The correct host name is set on X_FORWARDED_HOST. + +To get Laravel to use X_FORWARDED_HOST instead, edit the TrustProxies middleware and set $proxies to the * wildcard: + +``` class TrustProxies extends Middleware +{ +... + protected $proxies = '*'; +``` + ### Assets in templates Assets referenced in templates should be via the `asset()` helper: