Authentication
Learn how to authenticate with Visgate using API keys, server proxy, or session tokens.
Visgate supports three authentication methods depending on your environment.
API Key
The simplest approach. Set VISGATE_API_KEY as an environment variable or pass it directly to the client.
Provider keys are stored in Google Cloud Secret Manager, decrypted only in-memory for live API calls, scoped to your organization, and never written to logs or returned in API responses.
Server Proxy
For browser apps, never expose your API key in client-side code. Use a server-side proxy that injects the key before forwarding requests to Visgate.
The @visgate_ai/server-proxy package provides a ready-made proxy for Next.js and any Node.js server.
Next.js App Router
Create the proxy route:
Then configure the client:
Custom Server
For Express, Hono, or any Node.js server:
See Server Proxy Setup for full details.
Session Auth
When your app uses session tokens (e.g. Firebase ID tokens), pass a getToken function so the client sends a fresh Bearer token on each request. The proxy forwards it to the API.
If you use httpOnly cookies, the token is never in the client. Your proxy reads the cookie and adds Bearer on the server. In that case, do not use getToken — use Client({ proxyUrl: "/api/visgate" }) and ensure requests send credentials so the cookie is included.