From 2378f0fbe732bbad149f82e3267457d1aabee548 Mon Sep 17 00:00:00 2001 From: waiwai <511158080@qq.com> Date: Wed, 6 May 2026 11:10:14 +0800 Subject: [PATCH] fix: auto-detect Vercel for chat history path On Vercel, /var/task is read-only at runtime. ChatHistoryPath() now auto-detects Vercel via IsVercel() and defaults to /tmp/chat_history.json when no explicit DS2API_CHAT_HISTORY_PATH is set. Manual env var still works as explicit override. --- internal/config/paths.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/config/paths.go b/internal/config/paths.go index 7b8f22d..60f2829 100644 --- a/internal/config/paths.go +++ b/internal/config/paths.go @@ -58,6 +58,11 @@ func RawStreamSampleRoot() string { } func ChatHistoryPath() string { + // On Vercel, /var/task is read-only at runtime. If no explicit path is set, + // default to /tmp/chat_history.json (the only writable directory). + if IsVercel() && strings.TrimSpace(os.Getenv("DS2API_CHAT_HISTORY_PATH")) == "" { + return "/tmp/chat_history.json" + } return ResolvePath("DS2API_CHAT_HISTORY_PATH", "data/chat_history.json") }