From 1182e80e6aa8189613fe531598116fe11ee11aec Mon Sep 17 00:00:00 2001 From: Adam Brauer <400763+ambrauer@users.noreply.github.com> Date: Thu, 3 Feb 2022 07:57:35 -0600 Subject: [PATCH] #513289 Use more focused paths for Sitecore rewrites (similar to RAV / headless proxy) to avoid interference with allowed path "/sitecore/templates". This fixes an issue which prevented template standard values from being edited in Sitecore. --- .../src/lib/next-config/plugins/disconnected.js | 7 ++++--- .../src/templates/nextjs/next.config.js | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/lib/next-config/plugins/disconnected.js b/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/lib/next-config/plugins/disconnected.js index 80e92d7db5..57db70d284 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/lib/next-config/plugins/disconnected.js +++ b/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/lib/next-config/plugins/disconnected.js @@ -10,11 +10,12 @@ const disconnectedPlugin = (nextConfig = {}) => { return Object.assign({}, nextConfig, { async rewrites() { - // When disconnected we proxy to the local faux layout service host, see scripts/disconnected-mode-server.js + // When disconnected we proxy to the local faux layout service host, see scripts/disconnected-mode-proxy.ts return [ + // API endpoints { - source: '/sitecore/:path*', - destination: `${disconnectedServerUrl}/sitecore/:path*`, + source: '/sitecore/api/:path*', + destination: `${disconnectedServerUrl}/sitecore/api/:path*`, }, // media items { diff --git a/packages/create-sitecore-jss/src/templates/nextjs/next.config.js b/packages/create-sitecore-jss/src/templates/nextjs/next.config.js index 01683644c3..4587edac64 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs/next.config.js +++ b/packages/create-sitecore-jss/src/templates/nextjs/next.config.js @@ -47,9 +47,10 @@ const nextConfig = { async rewrites() { // When in connected mode we want to proxy Sitecore paths off to Sitecore return [ + // API endpoints { - source: '/sitecore/:path*', - destination: `${jssConfig.sitecoreApiHost}/sitecore/:path*`, + source: '/sitecore/api/:path*', + destination: `${jssConfig.sitecoreApiHost}/sitecore/api/:path*`, }, // media items { @@ -58,8 +59,8 @@ const nextConfig = { }, // visitor identification { - source: '/layouts/:path*', - destination: `${jssConfig.sitecoreApiHost}/layouts/:path*`, + source: '/layouts/system/:path*', + destination: `${jssConfig.sitecoreApiHost}/layouts/system/:path*`, }, ]; },