-
Notifications
You must be signed in to change notification settings - Fork 471
Default TCP port included in ControllerLinkBuilder - HTTP:80 vs HTTS:443 #301
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
Comments
So isn't that rather something you'd want to report in the Spring Framework JIRA? We're basically using I can see some changes made in the release for SPR-12723 but I can't quite see why the changes @jhoeller would cause a change in behavior. Looking at your example it seems that the request contains an explicit port 80 despite the fact its on HTTPS. According to the code in SUCB this will always have lead to the port explicitly added as it's not equal to 443. We apply some custom handling for |
This are my headers:
The output from ServletUriComponentsBuilder:
|
That looks weird. Care to create a test case that shows the lookup through |
@olivergierke I have a running example for you. Just upgraded to Spring Boot 1.2.2 and my website is not working any more. If you open https://www.jiwhiz.com by Chrome, and see the network traffic in Developer Tools, you can find the first api call to https://www.jiwhiz.com/api/public is 200 OK, but all hyperlinks in the response will have port 80, such as
My application is deployed to PWS and I'm using CloudFlare as proxy for SSL. You can see all the source code at https://github.com/jiwhiz/JiwhizBlogWeb Appreciate if you can help me fix this issue. Otherwise I will revert back to Spring Boot 1.2.1.RELEASE. |
I believe the problem lies in UriComponentsBuilder.fromHttpRequest:
In my case "X-Forwarded-Port" equals 443, hence is assigned to variable port. The builder never sets the port however because scheme == https && port == 443 (not !443). I have reported a bug in Spring project
The commit that broke this use case. |
Thanks for reporting this, I have exactly the same behavior in my spring boot app (deployed to heroku). |
Fixed in latest Spring 4.1.6 RELEASE. |
This hasn't been fixed. I'm still running into it with Spring Boot 1.2 and Spring 4.1.6. Had to revert to Spring Boot 1.1 and Spring 4.0.9 to make my API work again. Please reopen the ticket. |
There's not much we can do about this here as indicated as it's been a bug in Spring Framework accidentally adding this. Do you have a small sample app somewhere to show that the issue persists? |
I figured the reason and posted it to Spring's JIRA. Turns out you have to pass |
Hi,
Last weekend (feb 20), Spring 4.1.5 was release. After fetching this new version I've got an issue with the links generated by Spring-hateoas.
Example link before the update:
https://example.com/rest/mobile/users/1
Example link after the update:
https://example.com:80/rest/mobile/users/1
As you can see, it automatically append port 80 to the URL. The problem is that my rest back-end is running on a cloud platform heroku, which is using a reverse proxy to terminate the TLS (HTTPS).
This worked well before the update since the port was not automatically appended and the browser could figure out the port by negotiation. By hard coding it (by taking it form the original request), this auto detecting is not possible anymore.
Does someone has an idea on how to get around this problem? Is there a way to configure the URL building strategy (port appending on default 80/443 ports in particular) globally in spring-hateoas?
Best regards,
Bart
PS: when I deploy my REST back-end locally I use localhost:9090, which worked and still works well. So in some cases I need the TCP port to be appended, but in case of 80/443 http/https I'd like the port to be left out of the URL.
The text was updated successfully, but these errors were encountered: