From 62074c0142b36c78d159dd7993ca4f7d4657c7a6 Mon Sep 17 00:00:00 2001 From: Brian Giori Date: Fri, 10 Feb 2023 10:21:21 -0800 Subject: [PATCH] fix: use get instead of post (#12) --- packages/node/src/remote/client.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/node/src/remote/client.ts b/packages/node/src/remote/client.ts index d4aa1ba..d18d39a 100644 --- a/packages/node/src/remote/client.ts +++ b/packages/node/src/remote/client.ts @@ -76,22 +76,19 @@ export class RemoteEvaluationClient { ): Promise { const userContext = this.addContext(user || {}); const endpoint = `${this.config.serverUrl}/sdk/vardata`; + const encodedUser = Buffer.from(JSON.stringify(userContext)).toString( + 'base64', + ); const headers = { Authorization: `Api-Key ${this.apiKey}`, + 'X-Amp-Exp-User': encodedUser, }; - const body = JSON.stringify(userContext); - // CDN can only cache requests where the body is < 8KB - if (body.length > 8000) { - console.warn( - `[Experiment] encoded user object length ${body.length} cannot be cached by CDN; must be < 8KB`, - ); - } this.debug('[Experiment] Fetch variants for user: ', userContext); const response = await this.httpClient.request( endpoint, - 'POST', + 'GET', headers, - body, + null, timeoutMillis, ); if (response.status !== 200) {