This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk-next/server / GetEnginexServerOptions

GetEnginexServerOptions ​

Options of getEnginexServer.

Properties ​

baseUrl? ​

optional baseUrl?: string

Absolute gateway URL, e.g. https://gateway.operator.com. Default: the environment variable ENGINEX_GATEWAY_URL (server-only, no NEXT_PUBLIC_), read on every request.


locale? ​

optional locale?: string

Language sent in Accept-Language, e.g. pt-BR.


next? ​

optional next?: EnginexNextFetchOptions

next: { revalidate, tags } applied to every fetch of this client. A fetchOptions.next passed in a call wins field by field. Next's Data Cache includes the request headers in the key, so responses for different tenants (X-Original-Host sent to the gateway) or tokens (Authorization) never get mixed.


resolveHost? ​

optional resolveHost?: (headers) => string | undefined

Replaces tenant discovery entirely: receives the request headers and returns the operator's domain (ignores the default order and trustOriginalHost); returning undefined rejects with CONFIGURATION_ERROR. To reuse the client within the same request, define the function outside the component (memoization compares the reference).

Parameters ​

headers ​

Headers

Returns ​

string | undefined


tokenStore? ​

optional tokenStore?: TokenStore

Player tokens for authenticated calls on the server, e.g. await readCookieTokenStore() (the nextCookieTokenStore session). Default: an empty memoryTokenStore() (anonymous). The server client never renews the session (autoRefresh: false): renewal is left to the browser.

Do not combine with next.revalidate (nor with fetchOptions.next.revalidate in a call): the player's responses (balance, profile, transactions) would enter Next's Data Cache. They are kept apart by token (the Authorization is part of the key), but stored on the server and served stale to the same player until revalidated. For player data, leave next out.


trustOriginalHost? ​

optional trustOriginalHost?: boolean

Trusts the request's x-original-host header, which then comes before host and x-forwarded-host. Default: false. On a page request, x-original-host comes from the browser as it sent it: without a proxy.ts that overwrites it, anyone could choose the SSR operator (tenant). Only enable it if the app's proxy.ts writes x-original-host with the host on EVERY request that renders (the players' only does this on /api and /dev), e.g. matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'].