Skip to content

In Symfony, if first call is https, all routes to http get a :0, breaking routes #43

Closed
@jrmyio

Description

@jrmyio

I am testing PHP-PM with Symfony Framework, however I got into a problem with the Symfony Router. Whenever the first page loaded via PHP-PM is a HTTPS call, all routes to http pages will have a ":0" port at the end. For example, links on https://www.example.com/user-dashboard will create links to http pages that look like: http://www.example.com:0/.

I tried to find out why this was happening and apparently the Symfony\Component\Routing\RequestContext has a property called $httpPort that somehow is set to 0 instead of the default 80 if the first call is a HTTPs call.

I patched this in an ugly way in the Symfony.php by adding the following 2 lines:

        $app->handle($request);

        if ($app->getContainer()->has('router.request_context'))
            $app->getContainer()->get('router.request_context')->setHttpPort(80);

        $this->postHandle($app);

I am not sure what the correct way to handle this problem is, nor do I know why it becomes a "0" in the first place (whereas normally that doesn't happen in Symfony).

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