I have following code in my controller for route:
\Drupal::destination()->get(); return new TrustedRedirectResponse('http://www.google.com');
Which results in error:
LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\Core\Routing\TrustedRedirectResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (line 154 of core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).
How can I get destination without compromising TrustedRedirectResponse?
Or how should I use TrustedRedirectResponse not resulting in error?
(What is "controller provided cache metadata" and what is "leaked metadata"?)