From 1ba7b992d5f37d21d7eb3b039cd4c8c11335cd2b Mon Sep 17 00:00:00 2001 From: Artem Alexeyenko Date: Fri, 30 Sep 2022 09:58:17 -0400 Subject: [PATCH] Ensure headers from middleare are passed into NativeFetcher (#1177) * Ensure headers from middleare are passed into NativeFetcher * remove headers field on NativeFetcherOptions to avoid duplicates --- .../src/middleware/personalize-middleware.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/sitecore-jss-nextjs/src/middleware/personalize-middleware.ts b/packages/sitecore-jss-nextjs/src/middleware/personalize-middleware.ts index 18a8af4eba..dc0b550220 100644 --- a/packages/sitecore-jss-nextjs/src/middleware/personalize-middleware.ts +++ b/packages/sitecore-jss-nextjs/src/middleware/personalize-middleware.ts @@ -60,10 +60,17 @@ export class PersonalizeMiddleware { // NOTE: same here, we provide NativeDataFetcher for compatibility on Next.js Edge Runtime this.cdpService = new CdpService({ ...config.cdpConfig, - dataFetcherResolver: ({ timeout }: { timeout: number }) => { + dataFetcherResolver: ({ + timeout, + headers, + }: { + timeout: number; + headers?: Record; + }) => { const fetcher = new NativeDataFetcher({ debugger: debug.personalize, timeout, + headers, }); return (url: string, data?: unknown) => fetcher.fetch(url, data); },