Skip to content

Instantly share code, notes, and snippets.

@sudodoki
Last active April 26, 2026 20:42
Show Gist options
  • Select an option

  • Save sudodoki/a77904ec4ba2eabf66a956993f7a64c4 to your computer and use it in GitHub Desktop.

Select an option

Save sudodoki/a77904ec4ba2eabf66a956993f7a64c4 to your computer and use it in GitHub Desktop.
Serve Image for comfyui to share results over network
"""
ComfyUI Image Serve — custom node plugin
Adds a /remote/view endpoint that serves output images with proper
HTTP/1.1 headers, bypassing the HTTP/0.9 raw-byte response of /view.
Install: copy this directory to ComfyUI/custom_nodes/ and restart ComfyUI.
"""
import os
import folder_paths
from aiohttp import web
from server import PromptServer
@PromptServer.instance.routes.get("/remote/view")
async def remote_view(request):
filename = request.rel_url.query.get("filename", "")
subfolder = request.rel_url.query.get("subfolder", "")
image_type = request.rel_url.query.get("type", "output")
if not filename:
return web.Response(status=400, text="filename required")
type_map = {
"output": folder_paths.get_output_directory(),
"input": folder_paths.get_input_directory(),
"temp": folder_paths.get_temp_directory(),
}
base_dir = type_map.get(image_type)
if not base_dir:
return web.Response(status=400, text="invalid type")
filepath = os.path.realpath(os.path.join(base_dir, subfolder, filename))
if not filepath.startswith(os.path.realpath(base_dir)):
return web.Response(status=403, text="forbidden")
if not os.path.isfile(filepath):
return web.Response(status=404, text="not found")
with open(filepath, "rb") as f:
data = f.read()
return web.Response(
body=data,
headers={
"Content-Type": "image/png",
"Content-Disposition": "inline",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "no-cache",
},
)
# No custom nodes — this plugin only adds the HTTP route
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}

comfyui-image-serve

A minimal ComfyUI custom node plugin that adds a /remote/view endpoint serving output images with proper HTTP/1.1 headers.

ComfyUI's built-in /view endpoint returns raw image bytes with no HTTP headers (HTTP/0.9). Modern browsers and Node.js reject these responses outside of port 80. This plugin adds a drop-in replacement endpoint that wraps the same image data in a proper HTTP/1.1 response.

Install

  1. Copy this directory into your ComfyUI custom_nodes folder:
cp -r comfyui-image-serve /path/to/ComfyUI/custom_nodes/

Or clone directly:

cd /path/to/ComfyUI/custom_nodes
git clone git@gist.github.com:a77904ec4ba2eabf66a956993f7a64c4.git comfyui-image-serve
  1. Restart ComfyUI.

Usage

Replace calls to /view with /remote/view — the query parameters are identical:

http://<comfyui-host>:<port>/remote/view?filename=image.png&subfolder=&type=output

Supported type values: output, input, temp.

Why

ComfyUI's /view endpoint predates HTTP/1.0 standards enforcement in browsers. The response is raw bytes — no status line, no headers. Chromium rejects this for any connection not on port 80. This plugin uses aiohttp (ComfyUI's own web server) to serve the same file with a correct HTTP/1.1 200 OK response and Content-Type: image/png.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment