rafmacalaba's picture
fix: disable Next.js caching on dynamic GET routes and fetches
5a56f86
Raw
History Blame Contribute Delete
834 Bytes
import { getAnnotations } from '../../../utils/storage.js';
export const dynamic = 'force-dynamic';
export async function GET(request) {
try {
const { searchParams } = new URL(request.url);
const docIndex = searchParams.get('document_index');
const filter = docIndex !== null ? parseInt(docIndex, 10) : null;
const annotations = await getAnnotations(filter);
return new Response(JSON.stringify(annotations), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
} catch (error) {
console.error("Error fetching annotations:", error);
return new Response(
JSON.stringify({ error: "Failed to fetch annotations" }),
{ status: 500, headers: { 'Content-Type': 'application/json' } }
);
}
}