<p dir="auto">Hi !</p>
<p dir="auto">When the <code class="notranslate">asset</code> helper is used in a twig template to generate urls, it does not take into account the <code class="notranslate">router.request_context.base_url</code> parameter set in <code class="notranslate">config.yml</code> (or <code class="notranslate">config_*.yml</code>).</p>
<p dir="auto">I've created a <strong><a href="https://github.com/MrMitch/symfony-assets-base-url">sample project</a></strong> (based on <a href="https://github.com/symfony/symfony-standard">symfony/symfony-standard</a>) to illustrate this.</p>
<p dir="auto">The project defines a <a href="http://symfony.com/doc/current/cookbook/console/request_context.html" rel="nofollow">default base-url</a> for all requests in <a href="https://github.com/MrMitch/symfony-assets-base-url/blob/assets-base-url/app/config/config.yml#L10">config.yml</a>.<br>
Inside the project, i added a <a href="https://github.com/MrMitch/symfony-assets-base-url/blob/assets-base-url/src/AppBundle/Command/GenerateAssetsListCommand.php">demonstration command</a> <code class="notranslate">mitch:generate-assets-list</code> that ouputs 3 lists of urls.</p>
<ol dir="auto">
<li>a list generated with <code class="notranslate">asset</code></li>
<li>a list generated using <code class="notranslate">url</code></li>
<li>a list generated using <code class="notranslate">path</code></li>
</ol>
<p dir="auto">The urls of list 2 &amp; 3 all have the base-url part inside, the urls in list 1 do not.</p>
<p dir="auto"><a href="https://github.com/MrMitch/symfony-assets-base-url/blob/assets-base-url/src/AppBundle/Resources/views/template.twig">The template</a> looks like :</p>
<div class="highlight highlight-text-html-twig notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="## assets urls

- {{ asset('bundles/app/img/logo.png') }}
- {{ asset('bundles/framework/images/logo_symfony.png') }}

## controller urls

- {{ url('homepage') }}
- {{ url('dummy_route') }}

## controller paths

- {{ path('homepage') }}
- {{ path('dummy_route') }}"><pre class="notranslate">## assets urls

- {{ asset(<span class="pl-s"><span class="pl-pds">'</span>bundles/app/img/logo.png<span class="pl-pds">'</span></span>) }}
- {{ asset(<span class="pl-s"><span class="pl-pds">'</span>bundles/framework/images/logo_symfony.png<span class="pl-pds">'</span></span>) }}

## controller urls

- {{ url(<span class="pl-s"><span class="pl-pds">'</span>homepage<span class="pl-pds">'</span></span>) }}
- {{ url(<span class="pl-s"><span class="pl-pds">'</span>dummy_route<span class="pl-pds">'</span></span>) }}

## controller paths

- {{ path(<span class="pl-s"><span class="pl-pds">'</span>homepage<span class="pl-pds">'</span></span>) }}
- {{ path(<span class="pl-s"><span class="pl-pds">'</span>dummy_route<span class="pl-pds">'</span></span>) }}</pre></div>
<p dir="auto">The ouput generated by <code class="notranslate">php bin/console mitch:generate-assets-list</code> looks like :</p>
<div class="highlight highlight-text-md notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="## assets urls

- /bundles/app/img/logo.png
- /bundles/framework/images/logo_symfony.png

## controller urls

- http://localhost/subfolder/
- http://localhost/subfolder/dummy

## controller paths

- /subfolder/
- /subfolder/dummy"><pre class="notranslate"><span class="pl-mh">## <span class="pl-en">assets urls</span></span>

<span class="pl-v">-</span> /bundles/app/img/logo.png
<span class="pl-v">-</span> /bundles/framework/images/logo_symfony.png

<span class="pl-mh">## <span class="pl-en">controller urls</span></span>

<span class="pl-v">-</span> <span class="pl-corl">http://localhost/subfolder/</span>
<span class="pl-v">-</span> <span class="pl-corl">http://localhost/subfolder/dummy</span>

<span class="pl-mh">## <span class="pl-en">controller paths</span></span>

<span class="pl-v">-</span> /subfolder/
<span class="pl-v">-</span> /subfolder/dummy</pre></div>
<p dir="auto">Thank you for your time,<br>
Mitch.</p>
<p dir="auto"><strong>Symfony version(s) affected</strong>: 4.1.1</p>
<p dir="auto"><strong>Description</strong><br>
When running in environment <code class="notranslate">prod</code> with display errors off, I'm seeing in my <code class="notranslate">/var/log/nginx/error.log</code> lots of <code class="notranslate">out of memory exception</code>. I'm having to resort to running in dev environment to see that the error (in this instance) is because a directory isn't writeable.</p>
<p dir="auto">Why is an out of memory exception being reported in the logs, instead of something more sensible?</p>
<p dir="auto"><strong>How to reproduce</strong><br>
Switch to prod mode, and try to write to a non-writeable directory, and you should see the out of memory exception error in the server log.</p>