Find the forms and endpoints to protect
List the forms and endpoints of a site, then choose which to declare as protected actions.
Guide: BrowserX
The Noxtica documentation describes a release check for the consent mode: open the live page with the banner unanswered and confirm that only the core script and one token request run. This guide automates that check with a clean Chromium that BrowserX leases and your own Playwright script drives.
Written for sites you own. Commands come from each project's own documentation; check it before you rely on a flag.
Check the machine and create an API key. The key is printed once, together with the configuration snippet that holds its digest. Also create the snapshot key, because the example configuration refers to it even for an ephemeral session. Copy the example configuration, replace its API-key entry with the printed snippet, check the file and start the worker on the loopback interface.
browserx doctor
browserx keys new dev # prints the key once, with the [[auth.api_keys]] snippet
browserx snapshot-key new ./.browserx-keys/snapshot.key # the example configuration names this file
cp examples/browserx.toml browserx.toml # paste the printed snippet over its [[auth.api_keys]]
browserx config check browserx.toml
browserx serve --config browserx.tomlCreate a session with persistence ephemeral, with the command line or a POST to the sessions endpoint. An ephemeral session keeps nothing after it ends, which is what a consent check needs. The response holds a session object with its identifier and generation, a controller token and the DevTools address. That address contains the token, so treat it as a secret and keep it out of logs.
export BROWSERX_SERVER=http://127.0.0.1:7690
export BROWSERX_API_KEY=<the key printed by keys new>
browserx session create --persistence ephemeral # JSON: session, token, cdp_urlConnect your script to the leased browser over the DevTools address and use the browser's first context. Register the collected-event listener with an init script on that context, so it runs before any page script, because an event that already fired is not replayed. Then open the staging page with the banner unanswered.
import { chromium } from 'playwright-core';
const browser = await chromium.connectOverCDP(process.env.CDP_URL); // cdp_url from the session response: a secret
const context = browser.contexts()[0];
// Register the listener before any page script runs: an event that already fired is not replayed.
await context.addInitScript(() => {
window.__noxEvents = [];
document.addEventListener('noxtica:collected', (e) =>
window.__noxEvents.push({ detail: e.detail, mode: window.noxticaClient?.getConsent().mode }));
});
const page = await context.newPage();
const requests = [];
page.on('request', (r) => requests.push(`${r.method()} ${new URL(r.url()).pathname}`));
await page.goto(process.env.PAGE_URL, { waitUntil: 'load' });
await page.waitForFunction(() => window.__noxEvents?.length > 0, null, { timeout: 10_000 });With the mode api and nothing granted, the documentation expects the core script, one token request, a session token and a collected event that says consent is required. It expects no nox_ key in local storage, no device cookie and no IndexedDB database before the visitor answers. Read cookies from the browser context: the page's own cookie property hides HttpOnly cookies. Count the requests the page makes, remembering that the page's own document is one of them.
const expected = process.env.EXPECTED_MODE ?? 'api';
const state = await page.evaluate(async () => ({
events: window.__noxEvents,
noxKeys: Object.keys(localStorage).filter((k) => k.startsWith('nox_')),
sessionKeys: Object.keys(sessionStorage).length,
indexedDb: (await indexedDB.databases()).map((db) => db.name),
}));
const cookies = await context.cookies(); // includes HttpOnly cookies, which document.cookie hides
const failures = [];
const check = (ok, msg) => { if (!ok) failures.push(msg); };
check(requests.filter((r) => /\/noxtica-collector-core(\.[0-9a-f]+)?\.js$/.test(r)).length === 1, 'core script not requested exactly once');
check(requests.filter((r) => r === 'POST /client/token').length === 1, 'not exactly one token request');
check(state.events.length === 1 && state.events[0].mode === expected, `consent mode is not ${expected}`);
check(state.events[0]?.detail?.skipped === 'consent_required', 'collected event is not consent_required');
check(state.sessionKeys > 0, 'no session token stored');
check(state.noxKeys.length === 0, 'nox_ keys in localStorage');
check(cookies.length === 0, 'cookies set before consent');
check(state.indexedDb.length === 0, 'IndexedDB databases created');
await browser.close(); // disconnects only; step 5 releases the session
if (failures.length) { console.error(failures.join('\n')); process.exitCode = 1; }End the session through the BrowserX API or command line, with its generation and controller token, so the browser is closed and its profile removed. Closing your Playwright connection only disconnects; the browser stays until you release it.
browserx session release <session-id> --token <controller token>The reported mode equals the one you configured, the collected event carries the consent-required marker, and the page stored nothing in the device stores. A mode that differs means the domain setting changed or the wrong domain's key is on the page.
List the forms and endpoints of a site, then choose which to declare as protected actions.
Crawl a site you own and see which pages carry the Noxtica collector.
Load your page from a country you select and compare what the visitor and the collector see.