Deployment guide

Open Graph image API on cloudflare

If you use Cloudflare in front of the app, cache `GET /api/og/...` at the edge as suitable; the response includes cache headers. Do not expose your key in public HTML—build the URL in your origin when possible.

Use this guide when evaluating OGKit as a hosted Vercel OG alternative, screenshot-service alternative, or framework-neutral social preview image API. The important SEO rule is that canonical URLs, sitemap URLs, and generated image URLs should all use the same final HTTPS host.

Environment checklist

  • NEXT_PUBLIC_APP_URL=https://example.com
  • OGKIT_KEY=ogk_live_...
  • API_KEY_SALT=...

Production checklist

  • Cache public OG image GET requests at the edge.
  • Bypass cache for dashboard and account pages.
  • Use signed URLs for public generation controls.

Caching and crawlability

Cloudflare can cache generated images aggressively because the query string defines the image. Do not cache authenticated dashboard routes.

For SEO crawlers, avoid bot challenges on public pages, robots.txt, and sitemap.xml. If a crawler sees a challenge page or a redirect chain, it may mark otherwise valid pages as non-indexable.

Frequently asked questions

How do I deploy an Open Graph image API on cloudflare?

Deploy OGKit with a final HTTPS public URL, set the required environment variables, and generate image URLs from server-side code or build-time metadata.

Should sitemap and canonical URLs use the deployment URL or final domain?

They should use the final canonical HTTPS domain. Preview URLs, http URLs, and www variants can create redirect and indexability issues.

Can I cache generated OG images?

Yes. OGKit image URLs are deterministic, and generated PNG responses include cache headers. Keep query strings intact when caching.

Related pages

OGKit turns one HTTPS URL into a 1200×630 Open Graph image. Read the API reference, the Open Graph SEO guide, try the Playground, or sign in to create API keys.