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

Details for different port/address added #3124

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

granth23
Copy link
Contributor

Problem

The documentation lacked information about necessary configuration changes for users working with a port other than 8100 or a host other than localhost.

Solution

Updated the configuration file to include details for working with different ports or hosts. Added a note in the server documentation for user assistance regarding the same:

  • For a development server running on a port other than 8100, update the SERVER_ROOT_URL field with the correct port number.
  • For a development server running on a host other than localhost (e.g., GitHub Codespaces), update the SERVER_NAME and SERVER_ROOT_URL fields with the appropriate host details.

Action

  • Please review the added documentation and configuration file for clarity and completeness.
  • Let me know if any additional details or corrections are required.
  • If the changes look good, kindly proceed with merging the PR.

@granth23 granth23 closed this Jan 13, 2025
@granth23 granth23 reopened this Jan 13, 2025
Copy link
Member

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

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

Thanks for working on improving this!
I have some suggestions to limit the amount of modifications required and streamline the setup a bit.

docs/developers/devel-env.rst Outdated Show resolved Hide resolved
@@ -22,6 +22,9 @@ SQLALCHEMY_TIMESCALE_URI = "postgresql://listenbrainz_ts:listenbrainz_ts@lb_db/l
TIMESCALE_ADMIN_URI = "postgresql://postgres:postgres@lb_db/postgres"
TIMESCALE_ADMIN_LB_URI = "postgresql://postgres:postgres@lb_db/listenbrainz_ts"

# Server address
SERVER_NAME = "localhost:8100"
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why setting this SERVER_NAME is required?
I only see it use in the testing framework so i am wondering.

As mentioned in my previous comment, this could potentially use the value of SERVER_ROOT_URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In situations where generating absolute external URLs is required, such as during OAuth redirection, Flask relies on the SERVER_NAME configuration. Without setting SERVER_NAME, Flask defaults to localhost, which can lead to incorrect or invalid redirect URLs. To ensure OAuth and similar features point to the correct local or production URL, it is necessary to configure SERVER_NAME with the actual base URL of the application.

While SERVER_ROOT_URL serves as a full external-facing URL, it is not directly usable for Flask’s purposes since it includes the protocol (http:// or https://), which Flask does not interpret in SERVER_NAME. Therefore, the two values, while related, cannot be interchanged directly.

You can refer to the attached Flask Documentation.

Copy link
Member

Choose a reason for hiding this comment

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

Can you share a case where Flask generated invalid urls with the existing config?

Copy link
Member

Choose a reason for hiding this comment

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

@amCap1712 I tried it out, set my local web port to 8103 in docker-compose and API_URL in config.py.

MetaBrainz Oauth fails, I thought because the redirect_uri now has port 8103 which is not what my existing oauth app expects (and how we instruct users to create in the devdocs).
image

I assumed the issue would be resolved if I created a new application on MB with the correct port in the callback URL, but I get the same error.
invalid_client is not the error I expected though...
So I went back to using port 8100 and my existing MB application for oauth... and it does not work !

Something looks like it is wrong with OAuth.
Try logging out in your local LB instance and logging back in, see if it works for you?

listenbrainz/config.py.sample Outdated Show resolved Hide resolved
@granth23 granth23 requested a review from MonkeyDo January 15, 2025 05:13
@anshg1214 anshg1214 requested a review from amCap1712 January 16, 2025 17:49
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.

3 participants