1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-03 15:16:40 -04:00

fix /api/hits edge caching

This commit is contained in:
2025-03-27 11:43:44 -04:00
parent 0080c4925b
commit 558934284e
2 changed files with 16 additions and 7 deletions

View File

@ -7,6 +7,11 @@ const HitCounter = async ({ slug }: { slug: string }) => {
await connection();
try {
// if this is a new slug, redis will automatically create a new key and set its value to 0 (and then 1, obviously)
// https://upstash.com/docs/redis/sdks/ts/commands/string/incr
// TODO: maybe don't allow this? or maybe it's fine? kinda unclear how secure this is:
// https://nextjs.org/blog/security-nextjs-server-components-actions
// https://nextjs.org/docs/app/building-your-application/rendering/server-components
const hits = await redis.incr(slug);
// we have data!