Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# syntax=docker/dockerfile:1.7
# Dev image for local docker-compose. Source is bind-mounted at runtime;
# node_modules lives in an anonymous volume so the container's deps win over
# whatever (if anything) is in the host tree.

FROM node:22.22.2-bookworm-slim

ENV PNPM_HOME=/pnpm
ENV PATH=$PNPM_HOME:$PATH
ENV NEXT_TELEMETRY_DISABLED=1

RUN corepack enable && corepack prepare pnpm@9.5.0 --activate

WORKDIR /app

COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm install --frozen-lockfile --prefer-offline

EXPOSE 5050

CMD ["pnpm", "run", "dev"]
32 changes: 32 additions & 0 deletions src/app/api/revalidate/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { NextRequest, NextResponse } from "next/server";
import { revalidateTag } from "next/cache";

export const runtime = "nodejs";
export const dynamic = "force-dynamic";

export async function POST(req: NextRequest) {
const secret = process.env.REVALIDATE_SECRET;
if (!secret) {
return NextResponse.json({ error: "revalidation_disabled" }, { status: 503 });
}

const auth = req.headers.get("authorization");
if (auth !== `Bearer ${secret}`) {
return NextResponse.json({ error: "unauthorized" }, { status: 401 });
}

let body: { tag?: string; tags?: string[] };
try {
body = (await req.json()) as { tag?: string; tags?: string[] };
} catch {
return NextResponse.json({ error: "invalid_json" }, { status: 400 });
}

const tags = body.tags ?? (body.tag ? [body.tag] : []);
if (tags.length === 0) {
return NextResponse.json({ error: "no_tags" }, { status: 400 });
}

for (const tag of tags) revalidateTag(tag);
return NextResponse.json({ ok: true, revalidated: tags });
}
Loading
Loading