diff --git a/lib_comfyui/webui/reverse_proxy.py b/lib_comfyui/webui/reverse_proxy.py index e1d3813..78e7761 100644 --- a/lib_comfyui/webui/reverse_proxy.py +++ b/lib_comfyui/webui/reverse_proxy.py @@ -42,16 +42,16 @@ async def reverse_proxy(request: Request): async def async_iter_raw_patched(response, proxy_route): proxy_route_bytes = bytes(proxy_route, "utf-8") + paths_to_replace = [b"/scripts/", b"/extensions/", b"/webui_scripts/"] + replacements = [ + (b'/favicon', proxy_route_bytes + b'/favicon'), + *( + (b'from "' + path, b'from "' + proxy_route_bytes + path) + for path in paths_to_replace + ), + ] async for chunk in response.aiter_raw(): - paths_to_replace = [b"/scripts/", b"/extensions/", b"/webui_scripts/"] - replacements = [ - (b'/favicon', proxy_route_bytes + b'/favicon'), - *( - (b'from "' + path, b'from "' + proxy_route_bytes + path) - for path in paths_to_replace - ), - ] for substring, replacement in replacements: chunk = chunk.replace(substring, replacement) yield chunk