Alokai

defineGetConfigSwitcherHeader

Helper function to define getConfigSwitcherHeader callback for SDK modules.

The callback should return a string which will be sent to the Server Middleware as x-alokai-middleware-config-id header.

Signature

declare function defineGetConfigSwitcherHeader(
	callback: (params: GetConfigSwitcherHeaderParams
) => string): (params: GetConfigSwitcherHeaderParams) => string;

Parameters

NameRequiredTypeDescription
callbackRequired(params: GetConfigSwitcherHeaderParams) => string

Referenced Types

Examples

Deriving config id from pathname.

const getConfigSwitcherHeader = defineGetConfigSwitcherHeader(({ pathname }) => {
  return pathname?.startsWith('/electronics') ? 'electronics' : 'default';
});

Deriving config id from search params.

On this page