mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-07 01:45:27 +08:00
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.
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user