Skip to main content
Setting proxy in Libra.init() routes all SDK API requests (/api, /openai, /audio, /rag) through a host-controlled Backend-for-Frontend (BFF) instead of directly to baseUrl. Auth becomes the BFF’s responsibility: the localStorage token flow is disabled, and the browser never holds a Libra or customer token. Signing out (via Libra.signOut() or the widget’s sign-out menu item) removes the user’s identity link on the backend so the next re-authentication requires re-linking.

Prerequisites

This integration runs against staging and production only.

You provide to Libra

Required for each env (staging, production):

Libra provides to you

Implementation

First, the host page points the widget at your BFF. This sends the session cookie with every SDK request instead of a browser-held token:
Then the BFF runs the same logic for every proxied request (illustrative Python):

Notes

  • Forward both SDK-set headers untouched. The SDK sets X-Libra-SDK-Product-ID and X-Libra-SDK-Version on every request it makes. The strip_browser_headers(...) step above is exactly where an allowlist built from the SDK README drops the version header — the README documents only the first. When it is missing, the backend treats the client as a pre-0.10.1 SDK and re-inlines chat images as base64 instead of proxy URLs, bloating chat-history responses.
  • X-Libra-SDK-Product-ID-Token is only needed for products (aspi_cz, aspi_sk, jogtar_hu) because the access token is opaque.
  • X-Correlation-ID is your trace key: one UUID per request (or echo an inbound one), sent to Auth0 as correlation_id, to Libra as the header, and echoed in the error envelope.
  • Never log tokens (log the correlation ID instead), cache SDK responses, share a token across users, persist it, or return any token to the browser.
  • Error monitoring on the BFF is required (Sentry, Crashlytics, Datadog, or equivalent). The SDK only ever shows a generic error screen, so the BFF is the single place where auth failures are observable: report every enveloped error and every exhausted retry, tagged with its correlation_id. When a user reports a problem, that correlation ID is what both your support and Libra’s will use to trace the request end to end. Never attach tokens to the report.

What changes in the widget

  • The localStorage token flow is off; there is no Auth0 popup. A 401 from your BFF shows the login/link screen, any other error status shows the generic error page.
  • Libra.signOut() and the widget’s sign-out entry remove the identity link on the backend and emit unauthenticated / signout.
  • baseUrl no longer determines where backend calls go, but it is still used for handoffs into the main Libra app; see Chat handoff.