FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 261 forks source link

issue with missing port since 2.5.4 #384

Closed dmaicher closed 4 years ago

dmaicher commented 4 years ago

Since https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/pull/381 in my app the routes are all generated without a port.

Given I'm on page http://my-host.loc:81/.

2.5.3

fos.Router.setData({
    "base_url": "", "routes": {
        "foo": {
            "tokens": [["text", "\/foo\/"]],
            "defaults": [],
            "requirements": [],
            "hosttokens": [["text", "my-host.loc"]],
            "methods": ["GET", "POST"],
            "schemes": []
        },
    }, "prefix": "", "host": "my-host.loc:81", "port": 81, "scheme": "http", "locale": "en"
});
fos.Router.getInstance().generate('foo');

==> "/foo/"

2.5.4:


fos.Router.setData({
    "base_url": "", "routes": {
        "foo": {
            "tokens": [["text", "\/foo\/"]],
            "defaults": [],
            "requirements": [],
            "hosttokens": [["text", "my-host.loc"]],
            "methods": ["GET", "POST"],
            "schemes": []
        },
    }, "prefix": "", "host": "my-host.loc:81", "port": 81, "scheme": "http", "locale": "en"
});
fos.Router.getInstance().generate('foo');

==> "http://my-host.loc/foo/"

So on 2.5.3 the generated url was relative (and so was taking the correct port of the current url). Now in 2.5.4 the generated url is absolute without a port which breaks my app.

dmaicher commented 4 years ago

ping @dew326 maybe you have an idea how to fix this?

dew326 commented 4 years ago

I will take a look.

dew326 commented 4 years ago

Hi @dmaicher, I created the PR (https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/pull/391) could you check if this branch fixes your issue?

dmaicher commented 4 years ago

Fixed in https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/pull/391