React / Next.js Example
The example below shows a simple Next.js App Router route handler that verifies the authorization header, parses the payload, and passes the article to your CMS or database.
app/api/articles/route.ts
typescript
import { NextResponse } from "next/server";
export async function POST(request: Request) {
const token = request.headers.get("authorization") ?? "";
// 1. Verify Secret
if (token !== `Bearer ${process.env.GWR_WEBHOOK_TOKEN}`) {
return new NextResponse("Unauthorized", { status: 401 });
}
// 2. Parse Payload
const payload = await request.json();
// 3. Save to your DB/CMS
await saveArticle({
title: payload.title,
slug: payload.slug,
html: payload.content_html,
seo: {
metaDescription: payload.meta_description,
primaryKeyword: payload.primary_keyword,
schema: payload.schema_article_jsonld,
},
});
return NextResponse.json({ status: "ok" });
}After deploying this route, paste the full URL into your dashboard integration dialog and click Test & Connect. We expect a 200 response to persist your webhook configuration.
!
Hardening Checklist
- Wrap the handler in
try/catchand send structured logs if parsing fails. - Queue downstream work instead of doing heavy lifting inline.
- Rotate
GWR_WEBHOOK_TOKENregularly and rerun the dashboard test after each change. - Add alerts for non-200 responses so misconfigs surface quickly.
For SPA or hybrid stacks, keep the heavy lifting on the server. Accept the payload in a secure API route (Next.js, Remix, Express, Laravel, etc.), persist the article, and surface it to client components via your CMS or RPC layer. Never ship the bearer token to the browser.