Skip to main content
DEPLOYMENT

Vercel Deployment

Deploy Originary receipt verification on Vercel using Edge Runtime. Implement HTTP 402 gateway pattern with PEAC-Receipt verification at the edge.

Edge Middleware Pattern

Vercel Edge Runtime lets you run code at the network edge before requests reach your application. Use Vercel middleware to intercept requests, challenge agents with HTTP 402, and verify PEAC-Receipts before allowing access to protected routes.

This pattern keeps receipt verification logic separate from your application code and ensures sub-10ms verification latency globally.

5-Minute Quickstart

  1. Install Originary SDK: npm install @originary/vercel
  2. Create middleware.ts with Originary receipt verification
  3. Add ORIGINARY_API_KEY to Vercel environment variables
  4. Deploy: vercel deploy
  5. Middleware gates routes with 402 and verifies receipts at edge

Code Example

// middleware.ts
import { verifyReceipt } from '@originary/vercel'
import { NextResponse } from 'next/server'

export async function middleware(request: Request) {
  const receipt = request.headers.get('PEAC-Receipt')

  if (!receipt) {
    return new NextResponse('Payment Required', {
      status: 402,
      headers: { 'WWW-Authenticate': 'PEAC' }
    })
  }

  const valid = await verifyReceipt(receipt)
  if (!valid) {
    return new NextResponse('Invalid Receipt', { status: 403 })
  }

  return NextResponse.next()
}

export const config = {
  matcher: '/api/:path*'
}

Deploy with confidence on Vercel

Add receipt verification to your Vercel Edge Functions today.

Get Started for $1