{% if resource.media is not empty and app.request is defined %}
    {% set name = resource.media.name %}
    {% if name is empty %}
        {% set name = "Download"|trans %}
    {% endif %}

    <p class="download-pp">
        <a href="{{ app.request.schemeandhttphost ~ app.request.basePath ~ asset(resource.media.url) }}" target="_blank" class="download">{{ name }}</a>
        <span>| {{ resource.media.contentTypeShort }} {{ resource.media.getFileSize() }}</span>
    </p>
{% endif %}

{% if resource.media is not empty and app.request is defined %}
    {% set name = resource.media.name %}
    {% if name is empty %}
        {% set name = "Download"|trans %}
    {% endif %}

    <p class="download-pp">
        <a href="{{ absolute_url(asset(resource.media.url)) }}" target="_blank" class="download">{{ name }}</a>
        <span>| {{ resource.media.contentTypeShort }} {{ resource.media.getFileSize() }}</span>
    </p>
{% endif %}

Use absolute_url twig function instead of using app.request data
Use absolute_url twig function instead of using app.request data
