Edge Cache time as environment variable

This commit is contained in:
Xevion
2023-02-23 21:59:02 -06:00
parent c23fde54da
commit f1147d92af
3 changed files with 4 additions and 1 deletions

View File

@@ -20,10 +20,11 @@ export default async function handler(
return;
}
const diff = await getDistance();
// auth passed
res.setHeader('Cache-Control', 'max-age=0, s-maxage=60, stale-while-revalidate');
res.setHeader('Cache-Control', `max-age=0, s-maxage=${env.EDGE_CACHE_TIME_SECONDS}, stale-while-revalidate`);
// @ts-ignore
res.status(200).json({ diff, inRange: diff < env.MAX_DISTANCE });
}