From 19e18546dea507dd043039c9df81a60ac38f12f3 Mon Sep 17 00:00:00 2001 From: ccbikai Date: Sun, 8 Dec 2024 11:37:04 +0800 Subject: [PATCH] fix: adjust cursor handling for KV pagination Moves undefined fallback from client to server side for cursor parameter Ensures consistent pagination behavior when fetching links from KV storage This prevents potential edge cases where undefined cursor values could be handled differently between client and server. --- components/dashboard/links/Index.vue | 2 +- server/api/link/list.get.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/dashboard/links/Index.vue b/components/dashboard/links/Index.vue index 3409459..35b6611 100644 --- a/components/dashboard/links/Index.vue +++ b/components/dashboard/links/Index.vue @@ -11,7 +11,7 @@ async function getLinks() { const data = await useAPI('/api/link/list', { query: { limit, - cursor: cursor || undefined, + cursor, }, }) links.value = links.value.concat(data.links).filter(Boolean) // Sometimes cloudflare will return null, filter out diff --git a/server/api/link/list.get.ts b/server/api/link/list.get.ts index f2ab7db..433029c 100644 --- a/server/api/link/list.get.ts +++ b/server/api/link/list.get.ts @@ -10,7 +10,7 @@ export default eventHandler(async (event) => { const list = await KV.list({ prefix: `link:`, limit, - cursor, + cursor: cursor || undefined, }) if (Array.isArray(list.keys)) { list.links = await Promise.all(list.keys.map(async (key: { name: string }) => {