From 7808c75452642d347615c597cd1cf490fe021694 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Tue, 2 Dec 2025 15:06:33 -0800 Subject: [PATCH] fix cache key generation for POST requests with object bodies --- src/lib/api/adapters/base.adapter.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/api/adapters/base.adapter.ts b/src/lib/api/adapters/base.adapter.ts index 5417af84..a0777ebe 100644 --- a/src/lib/api/adapters/base.adapter.ts +++ b/src/lib/api/adapters/base.adapter.ts @@ -94,7 +94,13 @@ export abstract class BaseAdapter { const url = this.buildURL(path, options.query || options.params) // Generate a unique ID for this request (used for cancellation and caching) - const requestId = this.generateRequestId(path, options.method, options.body as string) + // Stringify body if it's an object to ensure proper cache key generation + const bodyString = options.body + ? typeof options.body === 'string' + ? options.body + : JSON.stringify(options.body) + : undefined + const requestId = this.generateRequestId(path, options.method, bodyString) // Check cache first if caching is enabled (support both cacheTime and cacheTTL) const cacheTime = options.cacheTTL ?? options.cacheTime ?? this.options.cacheTime