-
Notifications
You must be signed in to change notification settings - Fork 36
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
USF-1877: Headers from config #267
Conversation
…m config Signed-off-by: Stephen Rugh <[email protected]>
Signed-off-by: Stephen Rugh <[email protected]>
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
|
|
Signed-off-by: Stephen Rugh <[email protected]>
Signed-off-by: Stephen Rugh <[email protected]>
Signed-off-by: Stephen Rugh <[email protected]>
Signed-off-by: Stephen Rugh <[email protected]>
Signed-off-by: Stephen Rugh <[email protected]>
@@ -42,7 +42,7 @@ export default async function decorate(block) { | |||
}, | |||
}, | |||
context: { | |||
customerGroup: await getConfigValue('commerce-customer-group'), | |||
customerGroup: await getConfigValue('commerce.queryparam.cs.Magento-Customer-Group'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we dedupe the config, so that we only have values in one place when possible, then we will end up with quite a lot of these sort of calls, where the key doesn't really make sense in the context of what we're passing the value to.
So it's a choice, I guess. Either we keep multiple duplicated values within the config, so the keys are more explicit, or we remove extra values and rely on just a single config value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally the PLP and LS widget are updated to allow for passing of headers in a single headers
object rather than as top-level props on this "config" object. Then we could use the same iteration logic as the PDP dropin in this PR.
Signed-off-by: Stephen Rugh <[email protected]>
Signed-off-by: Stephen Rugh <[email protected]>
Signed-off-by: Stephen Rugh <[email protected]>
Signed-off-by: Stephen Rugh <[email protected]>
urlWithQueryParams.searchParams.append('Magento-Store-Code', await getConfigValue('commerce-store-code')); | ||
urlWithQueryParams.searchParams.append('Magento-Customer-Group', await getConfigValue('commerce-customer-group')); | ||
// Set some query parameters for use as a cache-buster. No other purpose. | ||
urlWithQueryParams.searchParams.append('ac-storecode', await getConfigValue('commerce.headers.cs.Magento-Store-Code')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
major change - we are reverting back to rely on headers for request data differentation. the only query param we add is now done for cache busting purposes.
Note!
The Ask
The headers and query parameters used by the PDP dropin are stored in the content space in config files. These values are read per key:
Therefore, new query params or headers must be added to the config AND to the codebase.
We want these headers to be managed entirely in config rather than requiring developers to make code changes.
The Solution
We can add config values with some consistent path, ie
commerce.headers.[scope].[header]
where scope is likepdp
andheader
is the string header key. The corresponding value will be injected as header or query param, programatically.The Downside
Assuming headers will be defined in this way, then there is potential for duplication in the config. For example if two dropins require the same value, there will be duplicate values, for example:
Additionally, there are places where these values are used but not as headers. For example, here used to be
getConfigValue('commerce-customer-group
) but we removed that entry to reduce duplication in config. However this results in coupling of that line to thecs.Magento-Customer-Group
header in config.Test URLs:
Validate this on any of the following: