INNER CODE UNIT · TypeScript
applyExperiments
namecheap/ilc · ilc/server/experiments/index.ts:92
export function applyExperiments(
request: PatchedFastifyRequest,
reply: ServerResponseFastifyReply,
rulesetOverride: Ruleset = defaultRulesetProvider.getRuleset(),
): void {
// i18n (which runs first) may already have redirected and flushed the response;
// appending a Set-Cookie then would throw ERR_HTTP_HEADERS_SENT.
if (reply.sent) {
return;
}
request.raw.ilcState = request.raw.ilcState ?? {};
const secure = config.get('client.protocol') === 'https' || forwardedProtoIsHttps(request);
// Kill-switch: when disabled, resolve against an EMPTY ruleset. That assigns nothing
// and mints no session, but still runs the orphan-cookie sweep in assignExperiments —
// so a visitor who was mid-experiment gets their stale `x-ab-*` cookies expired and