Auth Proxy Configuration
The createAuthProxy function creates a Next.js proxy that handles all authentication logic. This page covers all configuration options.
Basic Setup#
Configuration Options#
apiBaseUrl#
Required - Your backend API base URL.
cookies#
Required - Cookie configuration for token storage.
endpoints#
Backend endpoints for auth operations. All paths are relative to apiBaseUrl.
guestToken#
Configure guest token behavior.
access#
Route access control configuration.
i18n#
Internationalization support. Extracts locale from URL path and sets x-locale header for downstream route handlers.
How it works:
- User visits
/tr/blog - Proxy extracts
trfrom the first path segment - Sets
x-locale: trheader on the request - Route handlers can read this header
- API client automatically appends
?lang=trto backend requests
See the i18n documentation for full setup guide.
excludedPaths#
Paths to skip proxy entirely.
blockBrowserApiAccess#
Block direct browser access to API routes.
When enabled, requests with Accept: text/html to /api/* are redirected to /.
responseMappers#
Custom parsers for different backend response formats.
csrf#
CSRF protection configuration.
rateLimit#
Rate limiting configuration.
audit#
Audit logging configuration.
onError#
Global error handler.
beforeAuth#
Hook that runs before auth validation.
afterAuth#
Hook that runs after auth validation.