Baldinof / roadrunner-bundle

A RoadRunner worker integrated in your Symfony app
MIT License
266 stars 47 forks source link

An exception has been thrown during the rendering of a template ("Untrusted Host "localhost"."). #43

Closed treadmillian closed 3 years ago

treadmillian commented 3 years ago

Not sure if this is related to RoadRunner, but I don't get this issue when running as symfony serve.

Symfony: 4.4.24 PHP: 7.4.19

When trying to view the Symfony Profiler from the web debug toolbar, I get the following error;

An exception has been thrown during the rendering of a template ("Untrusted Host "localhost".").

I have the following set in .env

TRUSTED_PROXIES=127.0.0.1,localhost
TRUSTED_HOSTS='^localhost|127.0.0.1|rcdo\.co\.uk|ricardo-aea\.com$'

Stack Trace

Twig\Error\RuntimeError:
An exception has been thrown during the rendering of a template ("Untrusted Host "localhost".").

  at vendor/symfony/web-profiler-bundle/Resources/views/Profiler/layout.html.twig:111
  at Twig\Template->displayBlock()
     (var/cache/dev/twig/bf/bf12d20c267291994bfc0d5a4b846de275078686a9fccb5f5b0fd626ae1d0c88.php:76)
  at __TwigTemplate_9102b89c893e179c91ea85832b18f46998eea5494cd633f70b4cdd3e29ce6a17->doDisplay()
     (vendor/twig/twig/src/Template.php:405)
  at Twig\Template->displayWithErrorHandling()
     (vendor/twig/twig/src/Template.php:378)
  at Twig\Template->display()
     (var/cache/dev/twig/10/104477248445284e8d32cc7eefe233df929fb6d50050bcb9876c2e0a9f72a4bd.php:50)
  at __TwigTemplate_05509a347546813a6b94f12d615ba9543a7d7d8691d677c374ac16aac863a105->doDisplay()
     (vendor/twig/twig/src/Template.php:405)
  at Twig\Template->displayWithErrorHandling()
     (vendor/twig/twig/src/Template.php:378)
  at Twig\Template->display()
     (var/cache/dev/twig/6f/6f02f7ba6d86e2b9ca1bcb4ede44b100df6ea6f17e6e55fe4e11fb4bb62b8f54.php:50)
  at __TwigTemplate_829a4f5e0b60e96f12de1e08e8917f34f9c166d6e6a46d4986b0ad51984afdf2->doDisplay()
     (vendor/twig/twig/src/Template.php:405)
  at Twig\Template->displayWithErrorHandling()
     (vendor/twig/twig/src/Template.php:378)
  at Twig\Template->display()
     (vendor/twig/twig/src/Template.php:390)
  at Twig\Template->render()
     (vendor/twig/twig/src/TemplateWrapper.php:45)
  at Twig\TemplateWrapper->render()
     (vendor/twig/twig/src/Environment.php:318)
  at Twig\Environment->render()
     (vendor/symfony/web-profiler-bundle/Controller/ProfilerController.php:123)
  at Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController->panelAction()
     (vendor/symfony/http-kernel/HttpKernel.php:158)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor/symfony/http-kernel/HttpKernel.php:80)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor/symfony/http-kernel/Kernel.php:201)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (vendor/baldinof/roadrunner-bundle/src/Http/KernelHandler.php:45)
  at Baldinof\RoadRunnerBundle\Http\KernelHandler->handle()
  at Generator->current()
     (vendor/baldinof/roadrunner-bundle/src/Http/MiddlewareStack.php:94)
  at Baldinof\RoadRunnerBundle\Http\Runner->getResponse()
     (vendor/baldinof/roadrunner-bundle/src/Http/MiddlewareStack.php:72)
  at Baldinof\RoadRunnerBundle\Http\Runner->handle()
     (vendor/baldinof/roadrunner-bundle/src/Integration/PHP/NativeSessionMiddleware.php:34)
  at Baldinof\RoadRunnerBundle\Integration\PHP\NativeSessionMiddleware->process()
  at Generator->current()
     (vendor/baldinof/roadrunner-bundle/src/Http/MiddlewareStack.php:94)
  at Baldinof\RoadRunnerBundle\Http\Runner->getResponse()
     (vendor/baldinof/roadrunner-bundle/src/Http/MiddlewareStack.php:80)
  at Baldinof\RoadRunnerBundle\Http\Runner->handle()
     (vendor/baldinof/roadrunner-bundle/src/Integration/Doctrine/DoctrineORMMiddleware.php:59)
  at Baldinof\RoadRunnerBundle\Integration\Doctrine\DoctrineORMMiddleware->process()
  at Generator->current()
     (vendor/baldinof/roadrunner-bundle/src/Http/MiddlewareStack.php:94)
  at Baldinof\RoadRunnerBundle\Http\Runner->getResponse()
     (vendor/baldinof/roadrunner-bundle/src/Http/MiddlewareStack.php:80)
  at Baldinof\RoadRunnerBundle\Http\Runner->handle()
     (vendor/baldinof/roadrunner-bundle/src/Http/MiddlewareStack.php:34)
  at Baldinof\RoadRunnerBundle\Http\MiddlewareStack->handle()
  at Generator->current()
     (vendor/baldinof/roadrunner-bundle/src/Worker/Worker.php:61)
  at Baldinof\RoadRunnerBundle\Worker\Worker->start()
     (vendor/baldinof/roadrunner-bundle/src/Command/WorkerCommand.php:68)
  at Baldinof\RoadRunnerBundle\Command\WorkerCommand->execute()
     (vendor/symfony/console/Command/Command.php:255)
  at Symfony\Component\Console\Command\Command->run()
     (vendor/symfony/console/Application.php:1027)
  at Symfony\Component\Console\Application->doRunCommand()
     (vendor/symfony/framework-bundle/Console/Application.php:97)
  at Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand()
     (vendor/symfony/console/Application.php:273)
  at Symfony\Component\Console\Application->doRun()
     (vendor/symfony/framework-bundle/Console/Application.php:83)
  at Symfony\Bundle\FrameworkBundle\Console\Application->doRun()
     (vendor/symfony/console/Application.php:149)
  at Symfony\Component\Console\Application->run()
     (bin/console:42)           

Runtime Error: in vendor/symfony/web-profiler-bundle/Resources/views/Profiler/layout.html.twig (line 111)


                        <a class="sf-toggle btn btn-sm" data-toggle-selector="#sidebar-search" {% if tokens is defined or about is defined %}data-toggle-initial="display"{% endif %}>                            {{ include('@WebProfiler/Icon/search.svg') }} <span class="hidden-small">Search</span>                        </a>                        {{ render(path('_profiler_search_bar', request.query.all)) }}                    </div>                </div>                {% if templates is defined %}                    <ul id="menu-profiler">
Baldinof commented 3 years ago

Hi, it's hard to tell, we are setting trusted hosts here: https://github.com/Baldinof/roadrunner-bundle/blob/2.x/src/Worker/Worker.php#L49-L51

If you can provide a reproducer I'll have a look.

treadmillian commented 3 years ago

Identified the issue as caused by other libraries.