From 03b83732a47ffac3865847547c3c470d8f4613b1 Mon Sep 17 00:00:00 2001 From: Joel Uong <88680517+joeluong-sfcc@users.noreply.github.com> Date: Thu, 3 Oct 2024 17:03:33 -0400 Subject: [PATCH] Fix: update ssr.js to include new non ASCII encoding feature flag (#2048) * update ssr.js * update changelog --- packages/pwa-kit-create-app/CHANGELOG.md | 1 + .../assets/bootstrap/js/overrides/app/ssr.js.hbs | 10 +++++++++- .../@salesforce/retail-react-app/app/ssr.js.hbs | 10 +++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/pwa-kit-create-app/CHANGELOG.md b/packages/pwa-kit-create-app/CHANGELOG.md index 9c266187ae..311425041c 100644 --- a/packages/pwa-kit-create-app/CHANGELOG.md +++ b/packages/pwa-kit-create-app/CHANGELOG.md @@ -1,4 +1,5 @@ ## v3.8.0-dev (Aug 8, 2024) +- Update ssr.js templates to include new feature flag to encode non ASCII HTTP headers [#2048](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2048) ## v3.7.0 (Aug 7, 2024) diff --git a/packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/ssr.js.hbs b/packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/ssr.js.hbs index 58d851422e..aab2da5b26 100644 --- a/packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/ssr.js.hbs +++ b/packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/ssr.js.hbs @@ -36,7 +36,15 @@ const options = { // Set this to false if using a SLAS public client // When setting this to true, make sure to also set the PWA_KIT_SLAS_CLIENT_SECRET // environment variable as this endpoint will return HTTP 501 if it is not set - useSLASPrivateClient: {{answers.project.commerce.isSlasPrivate}} + useSLASPrivateClient: {{answers.project.commerce.isSlasPrivate}}, + + // If this is enabled, any HTTP header that has a non ASCII value will be URI encoded + // If there any HTTP headers that have been encoded, an additional header will be + // passed, `x-encoded-headers`, containing a comma separated list + // of the keys of headers that have been encoded + // There may be a slight performance loss with requests/responses with large number + // of headers as we loop through all the headers to verify ASCII vs non ASCII + encodeNonAsciiHttpHeaders: true } const runtime = getRuntime() diff --git a/packages/pwa-kit-create-app/assets/templates/@salesforce/retail-react-app/app/ssr.js.hbs b/packages/pwa-kit-create-app/assets/templates/@salesforce/retail-react-app/app/ssr.js.hbs index 58d851422e..aab2da5b26 100644 --- a/packages/pwa-kit-create-app/assets/templates/@salesforce/retail-react-app/app/ssr.js.hbs +++ b/packages/pwa-kit-create-app/assets/templates/@salesforce/retail-react-app/app/ssr.js.hbs @@ -36,7 +36,15 @@ const options = { // Set this to false if using a SLAS public client // When setting this to true, make sure to also set the PWA_KIT_SLAS_CLIENT_SECRET // environment variable as this endpoint will return HTTP 501 if it is not set - useSLASPrivateClient: {{answers.project.commerce.isSlasPrivate}} + useSLASPrivateClient: {{answers.project.commerce.isSlasPrivate}}, + + // If this is enabled, any HTTP header that has a non ASCII value will be URI encoded + // If there any HTTP headers that have been encoded, an additional header will be + // passed, `x-encoded-headers`, containing a comma separated list + // of the keys of headers that have been encoded + // There may be a slight performance loss with requests/responses with large number + // of headers as we loop through all the headers to verify ASCII vs non ASCII + encodeNonAsciiHttpHeaders: true } const runtime = getRuntime()