Skip to content

Commit

Permalink
Refs #33625: Tweak debug params name
Browse files Browse the repository at this point in the history
  • Loading branch information
soarer1004 committed Dec 13, 2024
1 parent ab1d431 commit 7259c40
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/lib/elastic.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ function adjustBackendProxyUrl (req, indexName, entityType, config) {
delete parsedQuery.request
delete parsedQuery.request_format
delete parsedQuery.response_format
delete parsedQuery.appVersion
delete parsedQuery.instanceId
delete parsedQuery['x-app-version']
delete parsedQuery['x-instance-id']
url = config.elasticsearch.host + ':' + config.elasticsearch.port + '/' + indexName + '/' + entityType + '/_search?' + queryString.stringify(parsedQuery)
} else {
parsedQuery._source_includes = parsedQuery._source_include
Expand Down
14 changes: 10 additions & 4 deletions src/platform/magento1/util.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import config from 'config'
import { getCurrentStoreCode } from '../../lib/util'

const DEBUG_HEADER_KEY = {
const DEBUG_QUERY_PARAM_KEY = {
APP_VERSION: 'x-app-version',
INSTANCE_ID: 'x-instance-id'
}
Expand All @@ -12,15 +12,21 @@ function addDebugHeaders (config, req) {
}

config.headers = {};
const queryString = require('query-string');
const parsedQuery = queryString.parseUrl(req.url).query

for (const headerKey of Object.values(DEBUG_HEADER_KEY)) {
const value = req.headers[headerKey];
for (const debugParamKey of Object.values(DEBUG_QUERY_PARAM_KEY)) {
let value = parsedQuery[debugParamKey];

if (!value) {
value = req.headers[debugParamKey];
}

if (!value) {
continue;
}

config.headers[headerKey] = value;
config.headers[debugParamKey] = value;
}

return config;
Expand Down

0 comments on commit 7259c40

Please sign in to comment.