APIFuse

Next.js App Router integration

Call APIFuse from server-side Next.js App Router code.

Next.js App Router integration

Use APIFuse from server-side App Router code. Keep APIFuse API keys in server-only configuration and return application-specific data to client components.

1. Validate input

Use the operation schema or a schema bundle artifact to validate incoming request data before calling APIFuse.

2. Call APIFuse from a route handler

import { NextResponse } from "next/server";

export async function POST(request: Request) {
  const input = await request.json();

  const response = await fetch(
    "https://api.apifuse.com/v1/kakaomap/search",
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.APIFUSE_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify(input),
      cache: "no-store",
    },
  );

  if (!response.ok) {
    return NextResponse.json(
      { error: "apifuse_request_failed" },
      { status: response.status },
    );
  }

  return NextResponse.json(await response.json());
}

3. Keep secrets on the server

Do not expose APIFuse API keys, provider credentials, or Connection IDs to browser code. Client components should call your application route, not the APIFuse gateway directly.