Skip to content

feat: handle port not set and reverse proxy#540

Merged
ramsayleung merged 3 commits intoramsayleung:masterfrom
ilteoood:master
Oct 22, 2025
Merged

feat: handle port not set and reverse proxy#540
ramsayleung merged 3 commits intoramsayleung:masterfrom
ilteoood:master

Conversation

@ilteoood
Copy link
Contributor

Description

With this PR I would like to handle a couple of scenarios:

  • when the port is not defined, use the protocol's default one (http 80, https 443)
  • an app build with rspotify is hosted behind a reverse proxy

Motivation and Context

When the app is containerized + behind a reverse proxy, using the reverse proxy url makes the server to fail to start.

Dependencies

List any dependencies that are required for this change.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Changing the test scenario for the get_socket_address function.

Is this change properly documented?

Please make sure you've properly documented the changes you're making.

Don't forget to add an entry to the CHANGELOG if necessary (new features, breaking changes, relevant internal improvements).

@gemini-code-assist
Copy link

Summary of Changes

Hello @ilteoood, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces significant improvements to how the application handles redirect URLs, particularly in containerized and reverse-proxied environments. It ensures that the get_socket_address function correctly resolves socket addresses by providing default ports for HTTP and HTTPS when missing, and by intelligently falling back to localhost for non-loopback addresses, thereby resolving issues where the server failed to start.

Highlights

  • Default Port Handling: The get_socket_address function now automatically assigns default ports (80 for HTTP, 443 for HTTPS) when a port is not explicitly specified in the redirect URL.
  • Reverse Proxy Support: The logic for determining the socket address has been enhanced to better support applications running behind a reverse proxy. If the provided URL is not a loopback address, it will now fall back to a localhost IP address with the determined port, preventing server startup failures in containerized environments.
  • HTTPS Scheme Support: The get_socket_address function now correctly processes URLs using the https scheme, in addition to http.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the get_socket_address function to support default ports for HTTP/HTTPS and to handle reverse proxy scenarios. The changes correctly implement the described logic by providing default ports when not specified and by falling back to a localhost address when the provided redirect URL host is not a loopback address. The test suite has been updated accordingly to cover these new cases.

I've found a couple of areas for improvement: one is a potential compilation error that needs to be addressed, and the other is a suggestion to improve code readability and maintainability.

@ramsayleung
Copy link
Owner

Thanks for your contribution, the logic looks good to me, but it would be better if you could simplify the duplicated pattern of how to get default port for HTTP and HTTPS :)

@ilteoood ilteoood requested a review from ramsayleung October 22, 2025 06:01
@ramsayleung ramsayleung merged commit 9ce1c35 into ramsayleung:master Oct 22, 2025
7 checks passed
@ilteoood
Copy link
Contributor Author

Thank you so much @ramsayleung !
Would it possible to see this released?

@ramsayleung ramsayleung mentioned this pull request Oct 23, 2025
4 tasks
@ramsayleung
Copy link
Owner

Request accepted and processed, v0.15.2 is out :)

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

Successfully merging this pull request may close these issues.

2 participants