diff --git a/.nycrc.json b/.nycrc.json index 7a8da8fdf..b950f0abf 100644 --- a/.nycrc.json +++ b/.nycrc.json @@ -16,4 +16,4 @@ "src/agents/org-detector/instructions.js", "src/controllers/demo.js" ] -} +} \ No newline at end of file diff --git a/package.json b/package.json index e38d882ce..92daec942 100644 --- a/package.json +++ b/package.json @@ -157,4 +157,4 @@ ], "ext": ".js, .cjs, .ejs, .css" } -} +} \ No newline at end of file diff --git a/src/controllers/llmo/llmo.js b/src/controllers/llmo/llmo.js index 46766d89d..587bd60f3 100644 --- a/src/controllers/llmo/llmo.js +++ b/src/controllers/llmo/llmo.js @@ -48,6 +48,7 @@ const LLMO_SHEETDATA_SOURCE_URL = 'https://main--project-elmo-ui-data--adobe.aem function LlmoController(ctx) { const accessControlUtil = AccessControlUtil.fromContext(ctx); + // Helper function to get site and validate LLMO config const getSiteAndValidateLlmo = async (context) => { const { siteId } = context.params; @@ -140,7 +141,7 @@ function LlmoController(ctx) { headers: { Authorization: `token ${env.LLMO_HLX_API_KEY || 'hlx_api_key_missing'}`, 'User-Agent': SPACECAT_USER_AGENT, - 'Accept-Encoding': 'gzip', + 'Accept-Encoding': 'br', }, }); @@ -152,7 +153,7 @@ function LlmoController(ctx) { // Get the response data const data = await response.json(); - // Return the data and let the framework handle the compression + // Return the data, pass through any compression headers from upstream return ok(data, { ...(response.headers ? Object.fromEntries(response.headers.entries()) : {}), }); @@ -236,7 +237,7 @@ function LlmoController(ctx) { headers: { Authorization: `token ${env.LLMO_HLX_API_KEY || 'hlx_api_key_missing'}`, 'User-Agent': SPACECAT_USER_AGENT, - 'Accept-Encoding': 'gzip', + 'Accept-Encoding': 'br', }, }); @@ -318,7 +319,7 @@ function LlmoController(ctx) { const totalDuration = methodEndTime - methodStartTime; 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)`); - // Return the data and let the framework handle the compression + // Return the data, pass through any compression headers from upstream return ok(data, { ...(response.headers ? Object.fromEntries(response.headers.entries()) : {}), }); @@ -361,7 +362,7 @@ function LlmoController(ctx) { headers: { Authorization: `token ${env.LLMO_HLX_API_KEY || 'hlx_api_key_missing'}`, 'User-Agent': SPACECAT_USER_AGENT, - 'Accept-Encoding': 'gzip', + 'Accept-Encoding': 'br', }, }); diff --git a/test/controllers/llmo/llmo.test.js b/test/controllers/llmo/llmo.test.js index dfcadbd5c..796fa4e26 100644 --- a/test/controllers/llmo/llmo.test.js +++ b/test/controllers/llmo/llmo.test.js @@ -299,7 +299,7 @@ describe('LlmoController', () => { headers: { Authorization: `token ${TEST_API_KEY}`, 'User-Agent': TEST_USER_AGENT, - 'Accept-Encoding': 'gzip', + 'Accept-Encoding': 'br', }, }); }); @@ -366,7 +366,7 @@ describe('LlmoController', () => { headers: { Authorization: 'token hlx_api_key_missing', 'User-Agent': TEST_USER_AGENT, - 'Accept-Encoding': 'gzip', + 'Accept-Encoding': 'br', }, }); });