Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use get instead of post #12

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions packages/node/src/remote/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,19 @@ export class RemoteEvaluationClient {
): Promise<Variants> {
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) {
Expand Down