create-content-sdk-app 1.4.0-canary.15 → 1.4.0-canary.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/templates/nextjs/next.config.js +10 -0
- package/dist/templates/nextjs/package.json +2 -2
- package/dist/templates/nextjs/sitecore.config.ts.example +2 -2
- package/dist/templates/nextjs/src/Layout.tsx +1 -1
- package/dist/templates/nextjs/src/components/content-sdk/FEAASScripts.tsx +4 -8
- package/dist/templates/nextjs/src/pages/api/editing/config.ts +1 -1
- package/dist/templates/nextjs/src/pages/api/editing/feaas/render.ts +1 -1
- package/dist/templates/nextjs/src/pages/api/editing/render.ts +1 -1
- package/dist/templates/nextjs/src/pages/api/healthz.ts +1 -1
- package/dist/templates/nextjs/src/pages/api/robots.ts +1 -1
- package/dist/templates/nextjs/src/pages/api/sitemap.ts +1 -1
- package/dist/templates/nextjs/src/{middleware.ts → proxy.ts} +19 -19
- package/dist/templates/nextjs-app-router/next.config.ts +10 -0
- package/dist/templates/nextjs-app-router/package.json +2 -2
- package/dist/templates/nextjs-app-router/sitecore.config.ts.example +2 -2
- package/dist/templates/nextjs-app-router/src/Layout.tsx +1 -1
- package/dist/templates/nextjs-app-router/src/app/[site]/[locale]/[[...path]]/not-found.tsx +19 -1
- package/dist/templates/nextjs-app-router/src/app/[site]/[locale]/[[...path]]/page.tsx +18 -6
- package/dist/templates/nextjs-app-router/src/app/[site]/layout.tsx +17 -5
- package/dist/templates/nextjs-app-router/src/app/api/robots/route.ts +0 -2
- package/dist/templates/nextjs-app-router/src/app/api/sitemap/route.ts +0 -2
- package/dist/templates/nextjs-app-router/src/app/not-found.tsx +19 -1
- package/dist/templates/nextjs-app-router/src/components/content-sdk/CdpPageView.tsx +2 -3
- package/dist/templates/nextjs-app-router/src/{middleware.ts → proxy.ts} +26 -26
- package/package.json +2 -2
|
@@ -7,6 +7,16 @@ const nextConfig = {
|
|
|
7
7
|
// Allow specifying a distinct distDir when concurrently running app in a container
|
|
8
8
|
distDir: process.env.NEXTJS_DIST_DIR || '.next',
|
|
9
9
|
|
|
10
|
+
// Enable Cache Components for explicit caching with "use cache" directive
|
|
11
|
+
// See: https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheComponents
|
|
12
|
+
cacheComponents: true,
|
|
13
|
+
|
|
14
|
+
// Enable Turbopack file system caching for faster dev startup (beta)
|
|
15
|
+
// See: https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack
|
|
16
|
+
experimental: {
|
|
17
|
+
turbopackFileSystemCacheForDev: true,
|
|
18
|
+
},
|
|
19
|
+
|
|
10
20
|
i18n: {
|
|
11
21
|
// These are all the locales you want to support in your application.
|
|
12
22
|
// These should generally match (or at least be a subset of) those in Sitecore.
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@sitecore-content-sdk/nextjs": "<%- version %>",
|
|
28
28
|
"@sitecore-feaas/clientside": "^0.6.0",
|
|
29
29
|
"@sitecore/components": "~2.1.0",
|
|
30
|
-
"next": "^
|
|
30
|
+
"next": "^16.1.1",
|
|
31
31
|
"next-localization": "^0.12.0",
|
|
32
32
|
"react": "^19.2.1",
|
|
33
33
|
"react-dom": "^19.2.1"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@typescript-eslint/parser": "8.39.0",
|
|
43
43
|
"cross-env": "~7.0.3",
|
|
44
44
|
"eslint": "^9.32.0",
|
|
45
|
-
"eslint-config-next": "15.
|
|
45
|
+
"eslint-config-next": "15.5.3",
|
|
46
46
|
"eslint-config-prettier": "^10.1.8",
|
|
47
47
|
"eslint-plugin-import": "2.32.0",
|
|
48
48
|
"eslint-plugin-jsdoc": "52.0.3",
|
|
@@ -32,7 +32,7 @@ export default defineConfig({
|
|
|
32
32
|
},
|
|
33
33
|
personalize: {
|
|
34
34
|
scope: process.env.NEXT_PUBLIC_PERSONALIZE_SCOPE,
|
|
35
|
-
edgeTimeout: parseInt(process.env.
|
|
36
|
-
cdpTimeout: parseInt(process.env.
|
|
35
|
+
edgeTimeout: parseInt(process.env.PERSONALIZE_PROXY_EDGE_TIMEOUT!, 10),
|
|
36
|
+
cdpTimeout: parseInt(process.env.PERSONALIZE_PROXY_EDGE_TIMEOUT!, 10),
|
|
37
37
|
},
|
|
38
38
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This Layout is needed for Starter Kit.
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import { JSX } from 'react';
|
|
5
5
|
import Head from 'next/head';
|
|
6
6
|
import { Placeholder, Field, DesignLibrary, Page } from '@sitecore-content-sdk/nextjs';
|
|
7
7
|
import Scripts from 'src/Scripts';
|
|
@@ -15,15 +15,11 @@ const FEAASScripts = (): JSX.Element => {
|
|
|
15
15
|
const shouldOptimize = (src: string) => {
|
|
16
16
|
if (src.startsWith('http')) {
|
|
17
17
|
const url = new URL(src);
|
|
18
|
-
const domains: string[] = nextConfig.images?.domains || [];
|
|
19
18
|
const remotePatterns = nextConfig.images?.remotePatterns || [];
|
|
20
|
-
return (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
pattern
|
|
24
|
-
pattern.protocol === url.protocol.slice(0, -1) &&
|
|
25
|
-
new RegExp('^' + convertToRegex(pattern.hostname) + '$').test(url.hostname)
|
|
26
|
-
)
|
|
19
|
+
return remotePatterns.some(
|
|
20
|
+
(pattern) =>
|
|
21
|
+
pattern.protocol === url.protocol.slice(0, -1) &&
|
|
22
|
+
new RegExp('^' + convertToRegex(pattern.hostname) + '$').test(url.hostname)
|
|
27
23
|
);
|
|
28
24
|
}
|
|
29
25
|
return true;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { type NextRequest
|
|
1
|
+
import { type NextRequest } from 'next/server';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@sitecore-content-sdk/nextjs/
|
|
3
|
+
defineProxy,
|
|
4
|
+
MultisiteProxy,
|
|
5
|
+
PersonalizeProxy,
|
|
6
|
+
RedirectsProxy,
|
|
7
|
+
} from '@sitecore-content-sdk/nextjs/proxy';
|
|
8
8
|
import sites from '.sitecore/sites.json';
|
|
9
9
|
import scConfig from 'sitecore.config';
|
|
10
10
|
|
|
11
|
-
export function
|
|
12
|
-
// Instantiate
|
|
13
|
-
// Each
|
|
14
|
-
const multisite = new
|
|
11
|
+
export default function proxy(req: NextRequest) {
|
|
12
|
+
// Instantiate proxies - they will use Edge config if available, otherwise fall back to local config
|
|
13
|
+
// Each proxy will skip processing if required API configuration is not available
|
|
14
|
+
const multisite = new MultisiteProxy({
|
|
15
15
|
/**
|
|
16
16
|
* List of sites for site resolver to work with
|
|
17
17
|
*/
|
|
18
18
|
sites,
|
|
19
19
|
...scConfig.api.edge,
|
|
20
20
|
...scConfig.multisite,
|
|
21
|
-
// This function determines if the
|
|
21
|
+
// This function determines if the proxy should be turned off on per-request basis.
|
|
22
22
|
// Certain paths are ignored by default (e.g. files and Next.js API routes), but you may wish to disable more.
|
|
23
|
-
// This is an important performance consideration since Next.js Edge
|
|
23
|
+
// This is an important performance consideration since Next.js Edge proxy runs on every request.
|
|
24
24
|
skip: () => false,
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
const redirects = new
|
|
27
|
+
const redirects = new RedirectsProxy({
|
|
28
28
|
/**
|
|
29
29
|
* List of sites for site resolver to work with
|
|
30
30
|
*/
|
|
@@ -32,24 +32,24 @@ export function middleware(req: NextRequest, ev: NextFetchEvent) {
|
|
|
32
32
|
...scConfig.api.edge,
|
|
33
33
|
...scConfig.api.local,
|
|
34
34
|
...scConfig.redirects,
|
|
35
|
-
// This function determines if the
|
|
35
|
+
// This function determines if the proxy should be turned off on per-request basis.
|
|
36
36
|
// Certain paths are ignored by default (e.g. Next.js API routes), but you may wish to disable more.
|
|
37
37
|
// By default it is disabled while in development mode.
|
|
38
|
-
// This is an important performance consideration since Next.js Edge
|
|
38
|
+
// This is an important performance consideration since Next.js Edge proxy runs on every request.
|
|
39
39
|
skip: () => false,
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
const personalize = new
|
|
42
|
+
const personalize = new PersonalizeProxy({
|
|
43
43
|
/**
|
|
44
44
|
* List of sites for site resolver to work with
|
|
45
45
|
*/
|
|
46
46
|
sites,
|
|
47
47
|
...scConfig.api.edge,
|
|
48
48
|
...scConfig.personalize,
|
|
49
|
-
// This function determines if the
|
|
49
|
+
// This function determines if the proxy should be turned off on per-request basis.
|
|
50
50
|
// Certain paths are ignored by default (e.g. Next.js API routes), but you may wish to disable more.
|
|
51
51
|
// By default it is disabled while in development mode.
|
|
52
|
-
// This is an important performance consideration since Next.js Edge
|
|
52
|
+
// This is an important performance consideration since Next.js Edge proxy runs on every request
|
|
53
53
|
skip: () => false,
|
|
54
54
|
// This is an example of how to provide geo data for personalization.
|
|
55
55
|
// The provided callback will be called on each request to extract geo data.
|
|
@@ -62,7 +62,7 @@ export function middleware(req: NextRequest, ev: NextFetchEvent) {
|
|
|
62
62
|
// },
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
return
|
|
65
|
+
return defineProxy(multisite, redirects, personalize).exec(req);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export const config = {
|
|
@@ -2,6 +2,16 @@ import type { NextConfig } from 'next';
|
|
|
2
2
|
import createNextIntlPlugin from 'next-intl/plugin';
|
|
3
3
|
|
|
4
4
|
const nextConfig: NextConfig = {
|
|
5
|
+
// Enable Cache Components for explicit caching with "use cache" directive
|
|
6
|
+
// See: https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheComponents
|
|
7
|
+
cacheComponents: true,
|
|
8
|
+
|
|
9
|
+
// Enable Turbopack file system caching for faster dev startup (beta)
|
|
10
|
+
// See: https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack
|
|
11
|
+
experimental: {
|
|
12
|
+
turbopackFileSystemCacheForDev: true,
|
|
13
|
+
},
|
|
14
|
+
|
|
5
15
|
// use this configuration to ensure that only images from the whitelisted domains
|
|
6
16
|
// can be served from the Next.js Image Optimization API
|
|
7
17
|
// see https://nextjs.org/docs/app/api-reference/components/image#remotepatterns
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@sitecore-content-sdk/nextjs": "<%- version %>",
|
|
34
34
|
"@sitecore-feaas/clientside": "^0.6.0",
|
|
35
35
|
"@sitecore/components": "~2.1.0",
|
|
36
|
-
"next": "^
|
|
36
|
+
"next": "^16.1.1",
|
|
37
37
|
"react": "^19.2.1",
|
|
38
38
|
"react-dom": "^19.2.1",
|
|
39
39
|
"next-intl": "^4.3.5"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@types/react-dom": "^19.2.3",
|
|
48
48
|
"cross-env": "^10.0.0",
|
|
49
49
|
"eslint": "^9.33.0",
|
|
50
|
-
"eslint-config-next": "15.5.
|
|
50
|
+
"eslint-config-next": "15.5.3",
|
|
51
51
|
"npm-run-all2": "^8.0.4",
|
|
52
52
|
"tailwindcss": "^4",
|
|
53
53
|
"typescript": "~5.8.3"
|
|
@@ -32,7 +32,7 @@ export default defineConfig({
|
|
|
32
32
|
},
|
|
33
33
|
personalize: {
|
|
34
34
|
scope: process.env.NEXT_PUBLIC_PERSONALIZE_SCOPE,
|
|
35
|
-
edgeTimeout: parseInt(process.env.
|
|
36
|
-
cdpTimeout: parseInt(process.env.
|
|
35
|
+
edgeTimeout: parseInt(process.env.PERSONALIZE_PROXY_EDGE_TIMEOUT!, 10),
|
|
36
|
+
cdpTimeout: parseInt(process.env.PERSONALIZE_PROXY_EDGE_TIMEOUT!, 10),
|
|
37
37
|
},
|
|
38
38
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Link from 'next/link';
|
|
2
2
|
import { headers } from 'next/headers';
|
|
3
|
+
import { Suspense } from 'react';
|
|
3
4
|
import { ErrorPage } from '@sitecore-content-sdk/nextjs';
|
|
4
5
|
import { parseRewriteHeader } from '@sitecore-content-sdk/nextjs/utils';
|
|
5
6
|
import client from 'lib/sitecore-client';
|
|
@@ -8,7 +9,8 @@ import Layout from 'src/Layout';
|
|
|
8
9
|
import Providers from 'src/Providers';
|
|
9
10
|
import { NextIntlClientProvider } from 'next-intl';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
// Component that handles headers access and error page fetching (uncached data access)
|
|
13
|
+
async function NotFoundContent() {
|
|
12
14
|
const headersList = await headers();
|
|
13
15
|
const { site, locale } = parseRewriteHeader(headersList);
|
|
14
16
|
|
|
@@ -35,3 +37,19 @@ export default async function NotFound() {
|
|
|
35
37
|
</div>
|
|
36
38
|
);
|
|
37
39
|
}
|
|
40
|
+
|
|
41
|
+
export default function NotFound() {
|
|
42
|
+
// Wrap the dynamic content in Suspense for Next.js 16 PPR compatibility
|
|
43
|
+
return (
|
|
44
|
+
<Suspense
|
|
45
|
+
fallback={
|
|
46
|
+
<div style={{ padding: 10 }}>
|
|
47
|
+
<h1>Page not found</h1>
|
|
48
|
+
<p>Loading...</p>
|
|
49
|
+
</div>
|
|
50
|
+
}
|
|
51
|
+
>
|
|
52
|
+
<NotFoundContent />
|
|
53
|
+
</Suspense>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isDesignLibraryPreviewData } from '@sitecore-content-sdk/nextjs/editing';
|
|
2
2
|
import { notFound } from 'next/navigation';
|
|
3
|
-
import { draftMode } from 'next/headers'
|
|
3
|
+
import { draftMode } from 'next/headers';
|
|
4
|
+
import { Suspense } from 'react';
|
|
4
5
|
<% if (prerender === 'SSG') { -%>
|
|
5
6
|
import { SiteInfo } from '@sitecore-content-sdk/nextjs';
|
|
6
7
|
import sites from '.sitecore/sites.json';
|
|
@@ -18,13 +19,10 @@ type PageProps = {
|
|
|
18
19
|
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
// Component that handles draft mode check and data fetching (uncached data access)
|
|
23
|
+
async function PageContent({ site, locale, path, searchParams }: { site: string; locale: string; path?: string[]; searchParams: Promise<{ [key: string]: string | string[] | undefined }> }) {
|
|
23
24
|
const draft = await draftMode();
|
|
24
25
|
|
|
25
|
-
// Set site and locale to be available in src/i18n/request.ts for fetching the dictionary
|
|
26
|
-
setRequestLocale(`${site}_${locale}`);
|
|
27
|
-
|
|
28
26
|
// Fetch the page data from Sitecore
|
|
29
27
|
let page;
|
|
30
28
|
if (draft.isEnabled) {
|
|
@@ -52,6 +50,20 @@ export default async function Page({ params, searchParams }: PageProps) {
|
|
|
52
50
|
);
|
|
53
51
|
}
|
|
54
52
|
|
|
53
|
+
export default async function Page({ params, searchParams }: PageProps) {
|
|
54
|
+
const { site, locale, path } = await params;
|
|
55
|
+
|
|
56
|
+
// Set site and locale to be available in src/i18n/request.ts for fetching the dictionary
|
|
57
|
+
setRequestLocale(`${site}_${locale}`);
|
|
58
|
+
|
|
59
|
+
// Wrap the dynamic content in Suspense for Next.js 16 PPR compatibility
|
|
60
|
+
return (
|
|
61
|
+
<Suspense fallback={<div>Loading...</div>}>
|
|
62
|
+
<PageContent site={site} locale={locale} path={path} searchParams={searchParams} />
|
|
63
|
+
</Suspense>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
55
67
|
<% if (prerender === 'SSG') { -%>
|
|
56
68
|
// This function gets called at build and export time to determine
|
|
57
69
|
// pages for SSG ("paths", as tokenized array).
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { draftMode } from 'next/headers';
|
|
2
|
+
import { Suspense } from 'react';
|
|
2
3
|
import Bootstrap from 'src/Bootstrap';
|
|
3
4
|
|
|
5
|
+
// Component that handles draft mode check (uncached data access)
|
|
6
|
+
async function SiteLayoutContent({ site, children }: { site: string; children: React.ReactNode }) {
|
|
7
|
+
const { isEnabled } = await draftMode();
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
<Bootstrap siteName={site} isPreviewMode={isEnabled} />
|
|
12
|
+
{children}
|
|
13
|
+
</>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
export default async function SiteLayout({
|
|
5
18
|
children,
|
|
6
19
|
params,
|
|
@@ -9,12 +22,11 @@ export default async function SiteLayout({
|
|
|
9
22
|
params: Promise<{ site: string }>;
|
|
10
23
|
}) {
|
|
11
24
|
const { site } = await params;
|
|
12
|
-
const { isEnabled } = await draftMode();
|
|
13
25
|
|
|
26
|
+
// Wrap the dynamic content in Suspense for Next.js 16 PPR compatibility
|
|
14
27
|
return (
|
|
15
|
-
<>
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
</>
|
|
28
|
+
<Suspense fallback={<>{children}</>}>
|
|
29
|
+
<SiteLayoutContent site={site}>{children}</SiteLayoutContent>
|
|
30
|
+
</Suspense>
|
|
19
31
|
);
|
|
20
32
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import Link from 'next/link';
|
|
2
|
+
import { Suspense } from 'react';
|
|
2
3
|
import client from 'lib/sitecore-client';
|
|
3
4
|
import scConfig from 'sitecore.config';
|
|
4
5
|
import { ErrorPage } from '@sitecore-content-sdk/nextjs';
|
|
5
6
|
import Layout from 'src/Layout';
|
|
6
7
|
import Providers from 'src/Providers';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
// Component that handles error page fetching (uncached data access)
|
|
10
|
+
async function NotFoundContent() {
|
|
9
11
|
if (scConfig.defaultSite) {
|
|
10
12
|
const page = await client.getErrorPage(ErrorPage.NotFound, {
|
|
11
13
|
site: scConfig.defaultSite,
|
|
@@ -29,3 +31,19 @@ export default async function NotFound() {
|
|
|
29
31
|
</div>
|
|
30
32
|
);
|
|
31
33
|
}
|
|
34
|
+
|
|
35
|
+
export default function NotFound() {
|
|
36
|
+
// Wrap the dynamic content in Suspense for Next.js 16 PPR compatibility
|
|
37
|
+
return (
|
|
38
|
+
<Suspense
|
|
39
|
+
fallback={
|
|
40
|
+
<div style={{ padding: 10 }}>
|
|
41
|
+
<h1>Page not found</h1>
|
|
42
|
+
<p>Loading...</p>
|
|
43
|
+
</div>
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
<NotFoundContent />
|
|
47
|
+
</Suspense>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { CdpHelper, useSitecore } from '@sitecore-content-sdk/nextjs';
|
|
3
|
-
import
|
|
3
|
+
import { useEffect, JSX } from 'react';
|
|
4
4
|
import { pageView } from '@sitecore-cloudsdk/events/browser';
|
|
5
5
|
import config from 'sitecore.config';
|
|
6
|
-
import { JSX } from 'react';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* This is the CDP page view component.
|
|
@@ -52,7 +51,7 @@ const CdpPageView = (): JSX.Element => {
|
|
|
52
51
|
page: route.name,
|
|
53
52
|
pageVariantId,
|
|
54
53
|
language,
|
|
55
|
-
}).catch(e => console.debug(e));
|
|
54
|
+
}).catch((e) => console.debug(e));
|
|
56
55
|
}, [mode, route, context.variantId, siteName]);
|
|
57
56
|
|
|
58
57
|
return <></>;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { type NextRequest
|
|
1
|
+
import { type NextRequest } from 'next/server';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from '@sitecore-content-sdk/nextjs/
|
|
3
|
+
defineProxy,
|
|
4
|
+
AppRouterMultisiteProxy,
|
|
5
|
+
PersonalizeProxy,
|
|
6
|
+
RedirectsProxy,
|
|
7
|
+
LocaleProxy,
|
|
8
|
+
} from '@sitecore-content-sdk/nextjs/proxy';
|
|
9
9
|
import sites from '.sitecore/sites.json';
|
|
10
10
|
import scConfig from 'sitecore.config';
|
|
11
11
|
import { routing } from './i18n/routing';
|
|
12
12
|
|
|
13
|
-
export function
|
|
14
|
-
//
|
|
15
|
-
const locale = new
|
|
13
|
+
export default function proxy(req: NextRequest) {
|
|
14
|
+
// LocaleProxy and AppRouterMultisiteProxy must always run for App Router routing
|
|
15
|
+
const locale = new LocaleProxy({
|
|
16
16
|
/**
|
|
17
17
|
* List of sites for site resolver to work with
|
|
18
18
|
*/
|
|
@@ -21,28 +21,28 @@ export function middleware(req: NextRequest, ev: NextFetchEvent) {
|
|
|
21
21
|
* List of all supported locales configured in routing.ts
|
|
22
22
|
*/
|
|
23
23
|
locales: routing.locales.slice(),
|
|
24
|
-
// This function determines if the
|
|
24
|
+
// This function determines if the proxy should be turned off on per-request basis.
|
|
25
25
|
// Certain paths are ignored by default (e.g. files and Next.js API routes), but you may wish to disable more.
|
|
26
|
-
// This is an important performance consideration since Next.js Edge
|
|
27
|
-
// in multilanguage scenarios, we need locale
|
|
26
|
+
// This is an important performance consideration since Next.js Edge proxy runs on every request.
|
|
27
|
+
// in multilanguage scenarios, we need locale proxy to always run first to ensure locale is set and used correctly by the rest of the proxies
|
|
28
28
|
skip: () => false,
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
const multisite = new
|
|
31
|
+
const multisite = new AppRouterMultisiteProxy({
|
|
32
32
|
/**
|
|
33
33
|
* List of sites for site resolver to work with
|
|
34
34
|
*/
|
|
35
35
|
sites,
|
|
36
36
|
...scConfig.multisite,
|
|
37
|
-
// This function determines if the
|
|
37
|
+
// This function determines if the proxy should be turned off on per-request basis.
|
|
38
38
|
// Certain paths are ignored by default (e.g. files and Next.js API routes), but you may wish to disable more.
|
|
39
|
-
// This is an important performance consideration since Next.js Edge
|
|
39
|
+
// This is an important performance consideration since Next.js Edge proxy runs on every request.
|
|
40
40
|
skip: () => false,
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
// Instantiate
|
|
44
|
-
// Each
|
|
45
|
-
const redirects = new
|
|
43
|
+
// Instantiate proxies - they will use Edge config if available, otherwise fall back to local config
|
|
44
|
+
// Each proxy will skip processing if required API configuration is not available
|
|
45
|
+
const redirects = new RedirectsProxy({
|
|
46
46
|
/**
|
|
47
47
|
* List of sites for site resolver to work with
|
|
48
48
|
*/
|
|
@@ -50,26 +50,26 @@ export function middleware(req: NextRequest, ev: NextFetchEvent) {
|
|
|
50
50
|
...scConfig.api.edge,
|
|
51
51
|
...scConfig.api.local,
|
|
52
52
|
...scConfig.redirects,
|
|
53
|
-
// This function determines if the
|
|
53
|
+
// This function determines if the proxy should be turned off on per-request basis.
|
|
54
54
|
// Certain paths are ignored by default (e.g. Next.js API routes), but you may wish to disable more.
|
|
55
55
|
// By default it is disabled while in development mode.
|
|
56
|
-
// This is an important performance consideration since Next.js Edge
|
|
56
|
+
// This is an important performance consideration since Next.js Edge proxy runs on every request.
|
|
57
57
|
skip: () => false,
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
const personalize = new
|
|
60
|
+
const personalize = new PersonalizeProxy({
|
|
61
61
|
/**
|
|
62
62
|
* List of sites for site resolver to work with
|
|
63
63
|
*/
|
|
64
64
|
sites,
|
|
65
65
|
...scConfig.api.edge,
|
|
66
66
|
...scConfig.personalize,
|
|
67
|
-
// This function determines if the
|
|
67
|
+
// This function determines if the proxy should be turned off on per-request basis.
|
|
68
68
|
// Certain paths are ignored by default (e.g. Next.js API routes), but you may wish to disable more.
|
|
69
69
|
// By default it is disabled while in development mode.
|
|
70
|
-
// This is an important performance consideration since Next.js Edge
|
|
70
|
+
// This is an important performance consideration since Next.js Edge proxy runs on every request.
|
|
71
71
|
// NOTE: Personalize requires Edge configuration and cannot work with local containers.
|
|
72
|
-
// The
|
|
72
|
+
// The proxy will disable itself if Edge config is not present.
|
|
73
73
|
skip: () => false,
|
|
74
74
|
// This is an example of how to provide geo data for personalization.
|
|
75
75
|
// The provided callback will be called on each request to extract geo data.
|
|
@@ -82,7 +82,7 @@ export function middleware(req: NextRequest, ev: NextFetchEvent) {
|
|
|
82
82
|
// },
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
return
|
|
85
|
+
return defineProxy(locale, multisite, redirects, personalize).exec(req);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
export const config = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-content-sdk-app",
|
|
3
|
-
"version": "1.4.0-canary.
|
|
3
|
+
"version": "1.4.0-canary.17",
|
|
4
4
|
"description": "Sitecore Content SDK initializer",
|
|
5
5
|
"bin": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"ts-node": "^10.9.2",
|
|
71
71
|
"typescript": "~5.8.3"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "c9137ad2f4478d4fe51195b43cde55440cbfde5a"
|
|
74
74
|
}
|