[Router] Declaring route with host and environment variable works in dev but not in prod
#62,111 opened on Oct 19, 2025
Description
Symfony version(s) affected
all
Description
Hi,
I spend some time to figure about a bug on generating URL when parameter (ex: route.host.app) is used in Route::host argument.
No issue during the development because the cache is correctly rebuilt with the env var value.
But when i build docker image, i explicitly build the symfony cache (to avoid building the cache each time containers start) and the cache file url_generating_routes.php contains empty value for host tokens.
I see the usage of env var is explicitly forbidden by the PR: https://github.com/symfony/symfony/pull/20687/files but when the env var is used through a parameter, the check didn't apply.
I'm not sure how we can add a check to help developers to see an error during development and not when deploying in production.
How to reproduce
Set route.host.app value is %env(resolve:ROUTE_HOST_APP)%
Declare route host like this
app:
resource:
path: ../src/Controller/
namespace: App\Controller
type: attribute
host: '%route.host.app%'
prefix: /
Possible Solution
No response
Additional Context
No response