Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Fix some issue with insecure browsers. (#13261)

comfyanonymous76b75f3ad755
diff --git a/server.py b/server.py
index 27b14825e..881da8e66 100644
--- a/server.py
+++ b/server.py
@@ -146,6 +146,10 @@ def is_loopback(host):
def create_origin_only_middleware():
@web.middleware
async def origin_only_middleware(request: web.Request, handler):
+ if 'Sec-Fetch-Site' in request.headers:
+ sec_fetch_site = request.headers['Sec-Fetch-Site']
+ if sec_fetch_site == 'cross-site':
+ return web.Response(status=403)
#this code is used to prevent the case where a random website can queue comfy workflows by making a POST to 127.0.0.1 which browsers don't prevent for some dumb reason.
#in that case the Host and Origin hostnames won't match
#I know the proper fix would be to add a cookie but this should take care of the problem in the meantime