From 72cc3de920e415f8fe16d55b21407ffda358eee6 Mon Sep 17 00:00:00 2001 From: bc-max Date: Tue, 1 Nov 2022 11:32:00 +0200 Subject: [PATCH] fix(storefront): strf-10193 Bad request for custom front matter: - formatting; - data from custom layouts is sent as a body but not a header now; --- CHANGELOG.md | 15 ++++++--------- server/plugins/renderer/renderer.module.js | 5 ++--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23f0548f6..30500dd95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,24 +1,21 @@ ## [5.3.1](https://github.com/bigcommerce/stencil-cli/compare/5.3.0...5.3.1) (2022-10-28) - ### Bug Fixes -* STRF-9781 Bump hapi dependencies ([#930](https://github.com/bigcommerce/stencil-cli/issues/930)) ([05cb607](https://github.com/bigcommerce/stencil-cli/commit/05cb6077497e3fee68578d04f95ab86f0b522c4d)) +- STRF-9781 Bump hapi dependencies ([#930](https://github.com/bigcommerce/stencil-cli/issues/930)) ([05cb607](https://github.com/bigcommerce/stencil-cli/commit/05cb6077497e3fee68578d04f95ab86f0b522c4d)) # [5.3.0](https://github.com/bigcommerce/stencil-cli/compare/5.2.5...5.3.0) (2022-10-28) - ### Bug Fixes -* **storefront:** bctheme-1284 Fix error on using scoped nested external templates ([#1003](https://github.com/bigcommerce/stencil-cli/issues/1003)) ([1964ff5](https://github.com/bigcommerce/stencil-cli/commit/1964ff58ebebce3a43d79df51b159dbf0b57301d)) -* STRF-10157 Added missing dependency ([#1013](https://github.com/bigcommerce/stencil-cli/issues/1013)) ([ebc3bdd](https://github.com/bigcommerce/stencil-cli/commit/ebc3bdd18dfdce066fa92224940d5351c75498e3)) -* STRF-10157 Divide docker image release and semantic ([#1012](https://github.com/bigcommerce/stencil-cli/issues/1012)) ([7a2f869](https://github.com/bigcommerce/stencil-cli/commit/7a2f869e59255310dc5dcff06642a56e2cafc3bc)) -* update changelog and add tag format w/o 'v' ([#1014](https://github.com/bigcommerce/stencil-cli/issues/1014)) ([26af8fa](https://github.com/bigcommerce/stencil-cli/commit/26af8fadcf47de16f80c1e2560b58857671679cc)) - +- **storefront:** bctheme-1284 Fix error on using scoped nested external templates ([#1003](https://github.com/bigcommerce/stencil-cli/issues/1003)) ([1964ff5](https://github.com/bigcommerce/stencil-cli/commit/1964ff58ebebce3a43d79df51b159dbf0b57301d)) +- STRF-10157 Added missing dependency ([#1013](https://github.com/bigcommerce/stencil-cli/issues/1013)) ([ebc3bdd](https://github.com/bigcommerce/stencil-cli/commit/ebc3bdd18dfdce066fa92224940d5351c75498e3)) +- STRF-10157 Divide docker image release and semantic ([#1012](https://github.com/bigcommerce/stencil-cli/issues/1012)) ([7a2f869](https://github.com/bigcommerce/stencil-cli/commit/7a2f869e59255310dc5dcff06642a56e2cafc3bc)) +- update changelog and add tag format w/o 'v' ([#1014](https://github.com/bigcommerce/stencil-cli/issues/1014)) ([26af8fa](https://github.com/bigcommerce/stencil-cli/commit/26af8fadcf47de16f80c1e2560b58857671679cc)) ### Features -* STRF-10157 Introduce Semantic Release ([#1008](https://github.com/bigcommerce/stencil-cli/issues/1008)) ([085684d](https://github.com/bigcommerce/stencil-cli/commit/085684dae7afef55b1681f6bf3236777fde1df4d)) +- STRF-10157 Introduce Semantic Release ([#1008](https://github.com/bigcommerce/stencil-cli/issues/1008)) ([085684d](https://github.com/bigcommerce/stencil-cli/commit/085684dae7afef55b1681f6bf3236777fde1df4d)) ### 5.2.5 (2022-10-18) diff --git a/server/plugins/renderer/renderer.module.js b/server/plugins/renderer/renderer.module.js index b1abff768..6504f0463 100644 --- a/server/plugins/renderer/renderer.module.js +++ b/server/plugins/renderer/renderer.module.js @@ -80,6 +80,7 @@ internals.getResponse = async (request) => { withoutPageQuery.searchParams.delete('page'); const { customLayouts } = internals.options; + const layouts = customLayouts || DEFAULT_CUSTOM_LAYOUTS_CONFIG; const httpOpts = { url: withoutPageQuery.toString(), @@ -89,7 +90,7 @@ internals.getResponse = async (request) => { extraHeaders: { host: storeUrlObj.host, stencil_custom_templates: customLayouts }, }), accessToken: internals.options.accessToken, - data: request.payload, + data: { ...request.payload, customLayouts: layouts }, method: request.method, maxRedirects: 0, // handle the redirects manually to handle the redirect location // If the response is an image it will be parsed wrongly, so we receive a raw data (stream) @@ -119,7 +120,6 @@ internals.getResponse = async (request) => { // clear when making a non-get request because smth may be changed cache.clear(); } - const response = await networkUtils.sendApiRequest(httpOpts); internals.processResHeaders(response.headers); @@ -156,7 +156,6 @@ internals.getResponse = async (request) => { * @param request * @param response * @param responseArgs - * @param customLayouts * @returns {*} */ internals.parseResponse = async (bcAppData, request, response, responseArgs) => {