Send SDK version as X-SDK-Version header

Move the cookie-banner SDK version from the POST consents
request body to a custom X-SDK-Version header sent on every
API call. The server now reads it from the header and the
CORS middleware allows it through preflight.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-27 10:17:30 +04:00
parent abafd817a8
commit b7a28573f7
4 changed files with 4 additions and 4 deletions

View File

@@ -288,7 +288,6 @@ export class CookieBannerClient {
version: cfg.version,
action,
consent_data: consentData,
sdk_version: __SDK_VERSION__,
};
void fetchJSON<ConsentRecord>(url, { method: "POST", body })
.then(() => void flush(this.bannerId))

View File

@@ -120,6 +120,7 @@ export async function fetchJSON<T>(
credentials: "omit",
headers: {
Accept: "application/json",
"X-SDK-Version": __SDK_VERSION__,
...(body !== undefined && { "Content-Type": "application/json" }),
...headers,
},