Skip to content

UrlGenerator too eager to include port number in absolute urls #8561

Closed
@TomiS

Description

@TomiS

I have Apache listening port 8080 and Varnish listening port 80. It seems when I generate an absolute url with router, it adds port 8080 automatically. I'd like not to have any explicit ports in url even if I generate absolute urls

It seems to happen because of this code in Routing component's UrlGenerator.php

if (self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) {
    $port = '';
    if ('http' === $scheme && 80 != $this->context->getHttpPort()) {
        $port = ':'.$this->context->getHttpPort();
    } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
        $port = ':'.$this->context->getHttpsPort();
    }

    $schemeAuthority = self::NETWORK_PATH === $referenceType ? '//' : "$scheme://";
    $schemeAuthority .= $host.$port;
}

Is this a bug or a feature or am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions