From f4ff92ae16ee3689028be50f04e581a0471c3d6c Mon Sep 17 00:00:00 2001 From: Adam Brauer <400763+ambrauer@users.noreply.github.com> Date: Thu, 9 Nov 2023 12:19:52 -0600 Subject: [PATCH] [Next.js] [XMC] Fix "Could not resolve site for name" error on XMC rendering host build (#1659) * Fix issue when prerendering 404/500 pages during build on XMC editing hosts * Bump @sitecore/components to latest (1.1.2) * CHANGELOG update --- CHANGELOG.md | 2 +- .../src/templates/nextjs-xmcloud/package.json | 2 +- .../src/templates/nextjs-xmcloud/src/Bootstrap.tsx | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa16b332b6..8b0db78699 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,7 +38,7 @@ Our versioning strategy is as follows: ### 🛠 Breaking Changes * `[create-sitecore-jss]` The `nextjs-personalize` initializer add-on template has been removed and is replaced by the `nextjs-xmcloud` initializer template. You can use the interactive prompts or the `--xmcloud` argument to include this template. ([#1653](https://github.com/Sitecore/jss/pull/1653)) -* `[templates/nextjs]` `[sitecore-jss-nextjs]` CloudSDK Integration ([#1652](https://github.com/Sitecore/jss/pull/1652)): +* `[templates/nextjs]` `[sitecore-jss-nextjs]` CloudSDK Integration ([#1652](https://github.com/Sitecore/jss/pull/1652)) ([#1659](https://github.com/Sitecore/jss/pull/1659)): * Removed the following properties from _PersonalizeMiddleware_: _getPointOfSale_, _clientKey_, _endpoint_. You now need to provide _sitecoreEdgeContextId_ as a replacement. * _PersonalizeMiddleware_ has transitioned to utilizing the _CloudSDK_ package, replacing the previous dependency on _Engage_. * Introduced _Context_ class, that is used to initialize the application Context and shared Software Development Kits (SDKs). Accessible within the _@sitecore-jss/sitecore-jss-nextjs/context_ submodule. diff --git a/packages/create-sitecore-jss/src/templates/nextjs-xmcloud/package.json b/packages/create-sitecore-jss/src/templates/nextjs-xmcloud/package.json index 4394f65580..48593c4f2b 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs-xmcloud/package.json +++ b/packages/create-sitecore-jss/src/templates/nextjs-xmcloud/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@sitecore/components": "^1.1.0", + "@sitecore/components": "^1.1.2", "@sitecore-cloudsdk/events": "^0.1.1", "@sitecore-feaas/clientside": "^0.4.12" } diff --git a/packages/create-sitecore-jss/src/templates/nextjs-xmcloud/src/Bootstrap.tsx b/packages/create-sitecore-jss/src/templates/nextjs-xmcloud/src/Bootstrap.tsx index a8f082c8bb..9e7be115d4 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs-xmcloud/src/Bootstrap.tsx +++ b/packages/create-sitecore-jss/src/templates/nextjs-xmcloud/src/Bootstrap.tsx @@ -1,6 +1,5 @@ import { SitecorePageProps } from 'lib/page-props'; import { context } from 'src/lib/context'; -import { siteResolver } from 'lib/site-resolver'; import config from 'temp/config'; /** @@ -8,15 +7,12 @@ import config from 'temp/config'; * that needs to happen early in the application's lifecycle. */ const Bootstrap = (props: SitecorePageProps): JSX.Element | null => { - const site = props.layoutData?.sitecore.context.site; - const siteInfo = siteResolver.getByName(site?.name || config.siteName); - /** * Initializes the application Context and associated Software Development Kits (SDKs). * This function is the entry point for setting up the application's context and any SDKs that are required for its proper functioning. * It prepares the resources needed to interact with various services and features within the application. */ - context.init({ siteName: siteInfo.name }); + context.init({ siteName: props.site?.name || config.siteName }); return null; };