From 9eb4f1cd2af0673dff83a36b93818adc16436028 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 5 Feb 2024 23:00:14 +0000 Subject: [PATCH] set Cache-Control response headers --- api/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/api/index.ts b/api/index.ts index 288264c..452e08b 100644 --- a/api/index.ts +++ b/api/index.ts @@ -1,4 +1,4 @@ -import { getLastCheckin } from '../lib/foursquare' +// import { getLastCheckin } from '../lib/foursquare' import { NomadListLocation, getNomadList } from '../lib/nomadlist' export const config = { @@ -14,7 +14,7 @@ declare type LocationResponse = { next: Location } -export async function GET(request: Request) { +export async function GET() { try { const nomadlist = await getNomadList() // const foursquare = await getLastCheckin() @@ -26,7 +26,11 @@ export async function GET(request: Request) { } as LocationResponse return new Response(JSON.stringify(response, null, 2), { - headers: { 'content-type': 'application/json' } + status: 200, + headers: { + 'Content-Type': 'application/json', + 'Cache-Control': 's-maxage=300, stale-while-revalidate=300' + } }) } catch (error) { return new Response(JSON.stringify(error, null, 2), { status: 500 })