Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheme missing in generated URL #377

Open
KhorneHoly opened this issue Jan 15, 2020 · 3 comments
Open

Scheme missing in generated URL #377

KhorneHoly opened this issue Jan 15, 2020 · 3 comments

Comments

@KhorneHoly
Copy link

Hi,

I've encountered an issue with the 2.5.3 release, after upgrading it from 2.3.1.

If we're generating an URL, the returned URL is missing the leading HTTP/HTTPS scheme. With that, the generated URL will be appended to the current URL from the browser instead of correctly redirect to the generated URL.

Example:

url = Routing.generate('base', {
    'itemId': 1234
});
console.log(url);

test.domain.de/base/1234

instead of

http://test.domain.de/base/1234

If I set the generated URL to a link or just redirect via javascript

window.location.href = url;

The browser will try to reach this url:

http://test.domain.de/base/test.domain.de/base/1234

Reverting back to release to 2.3.1 or manually add the missing schema fixed the issue for now.

window.location.href = schema + "//" + url;

Thank you for creating and maintaining this bundle, it's highly appreciated.

@metalmini
Copy link

Same problem here

@YoannChabert
Copy link

YoannChabert commented Mar 1, 2020

I got the problem when i upgraded this package :

"symfony/serializer": "^5.0.4"
to
"symfony/serializer": "^5.0.5"

With JsRouting in 2.5

@metalmini @KhorneHoly

Edit : I also deleted the content of bundles in my public dir

GKFX added a commit to camdram/camdram that referenced this issue Mar 23, 2020
FriendsOfSymfony/FOSJsRoutingBundle#377
results in incorrect URLs being generated in some cases. For me route to
activate the bug was running `yarn build` on my local machine, though
the production server seems fine.
@GKFX
Copy link

GKFX commented Mar 23, 2020

Not sure the expected behaviour is being described quite right. I believe the sample code

url = Routing.generate('base', {
    'itemId': 1234
});
console.log(url);

should result in no domain part at all, i.e. /base/1234. There's a final argument to generate the full URL,

url = Routing.generate('base', {
    'itemId': 1234
}, true);
console.log(url);

should give http://test.domain.de/base/1234.

This seems to be an intermittent fault. Having just downgraded then re-upgraded, the bug went away, and even prior to that the bug was only active if (in my project) I ran yarn encore production rather than yarn encore dev, for example.

GKFX added a commit to camdram/camdram that referenced this issue Oct 2, 2020
This was until now blocked by the restriction on new versions of
FOSJsRoutingBundle imposed in response to
FriendsOfSymfony/FOSJsRoutingBundle#377.

However after reviewing the (fairly small) diff bewteen the version that
seemed buggy and the version we reverted back to, there doesn't seem to
be any change capable of causing the bug, and it seems likely, as
suggested on that thread, that some other package like
symfony/serializer caused the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants