Skip to content

Commit 74df966

Browse files
fix: use brotli compression for elmo endpoints | LLMO-1076
Co-authored-by: Igor Grubic <[email protected]>
1 parent 65c8a9b commit 74df966

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

.nycrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
"src/agents/org-detector/instructions.js",
1717
"src/controllers/demo.js"
1818
]
19-
}
19+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@
157157
],
158158
"ext": ".js, .cjs, .ejs, .css"
159159
}
160-
}
160+
}

src/controllers/llmo/llmo.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const LLMO_SHEETDATA_SOURCE_URL = 'https://main--project-elmo-ui-data--adobe.aem
4848

4949
function LlmoController(ctx) {
5050
const accessControlUtil = AccessControlUtil.fromContext(ctx);
51+
5152
// Helper function to get site and validate LLMO config
5253
const getSiteAndValidateLlmo = async (context) => {
5354
const { siteId } = context.params;
@@ -140,7 +141,7 @@ function LlmoController(ctx) {
140141
headers: {
141142
Authorization: `token ${env.LLMO_HLX_API_KEY || 'hlx_api_key_missing'}`,
142143
'User-Agent': SPACECAT_USER_AGENT,
143-
'Accept-Encoding': 'gzip',
144+
'Accept-Encoding': 'br',
144145
},
145146
});
146147

@@ -152,7 +153,7 @@ function LlmoController(ctx) {
152153
// Get the response data
153154
const data = await response.json();
154155

155-
// Return the data and let the framework handle the compression
156+
// Return the data, pass through any compression headers from upstream
156157
return ok(data, {
157158
...(response.headers ? Object.fromEntries(response.headers.entries()) : {}),
158159
});
@@ -236,7 +237,7 @@ function LlmoController(ctx) {
236237
headers: {
237238
Authorization: `token ${env.LLMO_HLX_API_KEY || 'hlx_api_key_missing'}`,
238239
'User-Agent': SPACECAT_USER_AGENT,
239-
'Accept-Encoding': 'gzip',
240+
'Accept-Encoding': 'br',
240241
},
241242
});
242243

@@ -318,7 +319,7 @@ function LlmoController(ctx) {
318319
const totalDuration = methodEndTime - methodStartTime;
319320
log.info(`LLMO query completed - total duration: ${totalDuration}ms (fetch: ${fetchDuration}ms, inclusion: ${inclusionDuration}ms, filtering: ${filterDuration}ms, exclusion: ${exclusionDuration}ms, grouping: ${groupingDuration}ms, mapping: ${mappingDuration}ms)`);
320321

321-
// Return the data and let the framework handle the compression
322+
// Return the data, pass through any compression headers from upstream
322323
return ok(data, {
323324
...(response.headers ? Object.fromEntries(response.headers.entries()) : {}),
324325
});
@@ -361,7 +362,7 @@ function LlmoController(ctx) {
361362
headers: {
362363
Authorization: `token ${env.LLMO_HLX_API_KEY || 'hlx_api_key_missing'}`,
363364
'User-Agent': SPACECAT_USER_AGENT,
364-
'Accept-Encoding': 'gzip',
365+
'Accept-Encoding': 'br',
365366
},
366367
});
367368

test/controllers/llmo/llmo.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ describe('LlmoController', () => {
299299
headers: {
300300
Authorization: `token ${TEST_API_KEY}`,
301301
'User-Agent': TEST_USER_AGENT,
302-
'Accept-Encoding': 'gzip',
302+
'Accept-Encoding': 'br',
303303
},
304304
});
305305
});
@@ -366,7 +366,7 @@ describe('LlmoController', () => {
366366
headers: {
367367
Authorization: 'token hlx_api_key_missing',
368368
'User-Agent': TEST_USER_AGENT,
369-
'Accept-Encoding': 'gzip',
369+
'Accept-Encoding': 'br',
370370
},
371371
});
372372
});

0 commit comments

Comments
 (0)