diff --git a/server/app_legacy.py b/server/app_legacy.py index fcf8d76..2aae24a 100644 --- a/server/app_legacy.py +++ b/server/app_legacy.py @@ -1334,6 +1334,11 @@ def initialize_system(path: str, thinking_mode: bool = False): def run_server(path: str, thinking_mode: bool = False, port: int = DEFAULT_PORT, debug: bool = False): """运行Web服务器""" + if not os.environ.get("WEB_SESSION_COOKIE_NAME"): + # 浏览器 Cookie 按域名/路径隔离,不按端口隔离。 + # 同一台机器同时启动 8091/8092 等多个实例时,若都使用默认 "session", + # 登录 Cookie 会互相覆盖,表现为两个端口无法同时保持登录。 + app.config['SESSION_COOKIE_NAME'] = f"agents_session_{port}" initialize_system(path, thinking_mode) start_background_jobs() socketio.run(