Fixed Next.js Middleware, Added API Route Caching, and Removed Unused Packages

This commit is contained in:
Ahmad 2024-12-23 14:14:15 -05:00
parent a25d2bf951
commit a9bd470c68
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
5 changed files with 48 additions and 244 deletions

View file

@ -29,7 +29,14 @@ export async function GET(
take: 3,
});
return NextResponse.json(auditLogs);
return new NextResponse(JSON.stringify(auditLogs), {
status: 200,
headers: {
'Cache-Control': 'public, s-maxage=5',
'CDN-Cache-Control': 'public, s-maxage=60',
'Vercel-CDN-Cache-Control': 'public, s-maxage=3600',
},
});
} catch (error) {
return new NextResponse(JSON.stringify(error), { status: 500 });
}

View file

@ -34,7 +34,14 @@ export async function GET(
},
});
return NextResponse.json(card);
return new NextResponse(JSON.stringify(card), {
status: 200,
headers: {
'Cache-Control': 'public, s-maxage=1',
'CDN-Cache-Control': 'public, s-maxage=60',
'Vercel-CDN-Cache-Control': 'public, s-maxage=3600',
},
});
} catch (error) {
return new NextResponse(JSON.stringify(error), { status: 500 });
}