-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[REF-843] Automatically update api_url and deploy_url #1954
Conversation
When backend_port or frontend_port are provided, reformat the defaults for api_url and deploy_url to match. If either api_url or deploy_url are provided, then they are not implicitly updated (respect the user decision) Fix REF-843
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, tested and works well for me. Not sure if we need to set the deploy_url
though, as it doesn't make sense for it to be localhost
* Get the URL for the websocket connection | ||
* @returns The websocket URL object. | ||
*/ | ||
export const getEventURL = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're modifying it here, the api_url
printed in the debug logs will show the wrong one still. Is it possible to modify the api_url
on the Python side instead? Or maybe not since this case handles it wherever they end up deploying it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The api_url in the logs will show whatever it is set to, there's no real way to munge that correctly on the python side.
I suppose a possible alternative would be to leave "localhost" alone and instead make the magic 0.0.0.0
mean "wherever i end up"?
"deploy_url" not in self._non_default_attributes | ||
and "frontend_port" in kwargs | ||
): | ||
self.deploy_url = f"http://localhost:{kwargs['frontend_port']}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the deploy_url
should ever be localhost. We only use this currently for the NextJS sitemap for indexing websites
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default deploy_url
is already "localhost" in the Config
... what should it be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess localhost
is accurate in dev mode, it's just currently only used for the sitemap so it's a bit meaningless.
When backend_port or frontend_port are provided, reformat the defaults for api_url and deploy_url to match.
If either api_url or deploy_url are provided, then they are not implicitly updated (respect the user decision)
Fix REF-843
After this change, just setting
reflex run --backend-port
will just work without additional configuration. Also, testing apps on other devices is easier, because the API_URL does not need to be set.