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

Added the ability to disable port #210

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib_comfyui/webui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def create_section():
shared.opts.onchange("comfyui_reverse_proxy_enabled", update_reverse_proxy_enabled)
update_reverse_proxy_enabled()

shared.opts.add_option("comfyui_reverse_proxy_disable_port", shared.OptionInfo(False,'Disable using the port when using reverse_proxy. Useful if using a nginx server',section=section))


@ipc.restrict_to_process('webui')
def update_enabled():
Expand Down Expand Up @@ -161,7 +163,7 @@ def get_comfyui_client_url():

def canonicalize_url(input_url: str, default_port: int = 8189) -> str:
from urllib.parse import urlparse, urlunparse

from modules import shared
# Step 1: Prepend 'http://' if scheme is missing
if not input_url.startswith(('http://', 'https://')):
input_url = 'http://' + input_url
Expand All @@ -173,8 +175,9 @@ def canonicalize_url(input_url: str, default_port: int = 8189) -> str:
scheme = parsed.scheme if parsed.scheme else 'http'

# Step 4: Add the missing port
disable_port = shared.opts.data.get('comfyui_reverse_proxy_disable_port',False)
netloc = parsed.netloc
if ':' not in netloc: # Check if port is missing
if ':' not in netloc and not disable_port: # Check if port is missing
netloc += f":{default_port}"
elif netloc.count(':') == 1 and parsed.scheme: # If port exists but scheme was present in input
host, port = netloc.split(':')
Expand Down
Loading