Server-side gateway demo

Stop rewriting proxy boilerplate.

A runnable Next.js 15 project that implements every published `@pajarrahmansyah/passit` feature through App Router route handlers.

8

demo routes

3

services

2

adapters

Live Route Runner

Basic proxy

/api/basic?_limit=3

Ready to send

Select a PassIt route and run it to inspect the normalized response.

Route Handler Proxy

Forward client requests through App Router endpoints while the backend URL stays server-side.

Multi Service Config

Switch between JSONPlaceholder, httpbin, and an axios-backed service by key.

Header Injection

Add static config headers and route-level headers without exposing API keys.

Timeout + Retry

Set global defaults and override retry behavior per route for server errors.

Normalization

Wrap success and error responses into a consistent shape for frontend consumers.

Response Transform

Map backend payloads into the exact contract your app wants to render.

Hooks

Use request, response, and error hooks for development logs or production observability.

Fetch + Axios

Exercise the default fetch adapter and the optional axios adapter in one demo app.

Config in `passit.config.ts`

export default defineConfig({
  json: {
    baseUrl: "https://jsonplaceholder.typicode.com",
    http: "fetch",
    headers: { "x-passit-app": "nextjs-15-example" },
    timeout: 5000,
    normalize: { success: true, error: true },
  },
  axiosJson: {
    baseUrl: "https://jsonplaceholder.typicode.com",
    http: "axios",
    normalize: true,
  },
})

Route handler usage

export async function GET(req: NextRequest) {
  return passIt({
    service: "json",
    path: "/posts",
    req,
    normalize: false,
    response: (posts) => ({
      count: posts.length,
      preview: posts.slice(0, 5),
    }),
  })
}