---
url: https://game-engine-io.github.io/enginex-frontend-sdk/concepts/tenant.md
---
# Tenant and domains

The gateway is multi-operator: each request must say **which operator** it belongs to. The gateway finds the
operator by the player's site **domain**, in the order `X-Original-Host` → `X-Forwarded-Host` → `Host`.
An `X-Tenant-ID` sent by the client is ignored.

## Recommended: same-origin proxy

With an empty `baseUrl` (the default), the SDK calls `/api/v1/...` on the page's origin and sends
`X-Original-Host: location.host`. Your server forwards `/api` to the gateway (see
[Installation](/guide/installation)). No CORS is involved and the site's domain identifies the operator.

## Direct call to the gateway (cross-origin)

With `baseUrl: 'https://api.operador.com'` in the browser, the SDK does **not** send `X-Original-Host`, because the
gateway's CORS does not allow that header and the preflight would fail (this holds even if you provide
`tenantHost`: in the browser it is only used on same-origin calls). In that case the operator is identified
by the `Host`, so **the domain `api.operador.com` must be registered as an operator domain**
in EngineX, and the site's origin must be allowed in CORS.

## Server {#server}

Outside the browser there is no `location`. Provide both:

```ts
createEnginexClient({ baseUrl: 'https://gateway.operador.com', tenantHost: 'casino.operador.com' })
```

Without them, `createEnginexClient` **does not throw on creation**: the resolution of the tenant (and of `fetch`) is
lazy, computed and memoized only on the first request — which matters for SDK singletons
imported in a top-level module during SSR (Next.js, Nuxt), before `location` even exists. If an
absolute `baseUrl` or `tenantHost` is missing at the time of that first request, it rejects with
`EnginexError` `CONFIGURATION_ERROR`, without calling `fetch`. A resolution that failed is **not
memoized**: the next request tries again (for example, if `location` comes to exist later).
See [Next.js / SSR](/guide/getting-started).

## Operator checklist

1. Site domain registered with the operator (EngineX Admin).
2. `/api` proxy → gateway, **or** gateway domain registered + origin allowed in CORS.
3. In SSR, `tenantHost` equal to the site's domain.
