Node.js Quickstart
Call your project's gateway API from an external Node.js service.
There is no hosted Nebutra API and no @nebutra/sdk package. If you need another Node.js service
ā outside apps/web ā to talk to your scaffolded project's gateway, call it over HTTP like any
other internal service.
Service-to-service authentication
Internal calls use a short-lived HS256 JWT (x-service-token), signed and verified with
@nebutra/auth's signServiceToken / verifyServiceToken, backed by the shared SERVICE_SECRET.
This is not an end-user session token ā it authenticates a trusted internal caller.
import { signServiceToken } from "@nebutra/auth";
const token = signServiceToken({ service: "my-node-worker" });
const res = await fetch("https://your-gateway-host/api/v1/ai/models", {
headers: { "x-service-token": token },
});If your Node service lives outside the monorepo and can't import @nebutra/auth directly, sign an
HS256 JWT with the same SERVICE_SECRET and claim shape by hand ā the gateway's
verifyServiceToken accepts any correctly signed token, not just ones minted by the package.
Calling the gateway as an end user
For requests made on behalf of a signed-in user (not a trusted internal service), forward the
Better Auth session cookie or bearer token the same way apps/web does ā there is no separate
API-key scheme for this.
Related
How is this guide?
Last updated on