Files
klz-cables.com/.pnpm-store/v10/files/d9/7520079447954b2645d49e292a67fcd68d9a04ec5b97c636aa1b43d8f0ad9d7aa188a99672e30504d776267307f5d59369e888c3f84c713fde6b739d034354
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

37 lines
1.4 KiB
Plaintext

import { headers } from 'next/headers';
import { cache } from 'react';
import { HEADER_LOCALE_NAME } from '../../shared/constants.js';
import { isPromise } from '../../shared/utils.js';
import { getCachedRequestLocale } from './RequestLocaleCache.js';
async function getHeadersImpl() {
const promiseOrValue = headers();
// Compatibility with Next.js <15
return isPromise(promiseOrValue) ? await promiseOrValue : promiseOrValue;
}
const getHeaders = cache(getHeadersImpl);
async function getLocaleFromHeaderImpl() {
let locale;
try {
locale = (await getHeaders()).get(HEADER_LOCALE_NAME) || undefined;
} catch (error) {
if (error instanceof Error && error.digest === 'DYNAMIC_SERVER_USAGE') {
const wrappedError = new Error('Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `setRequestLocale` API to enable static rendering, see https://next-intl.dev/docs/routing/setup#static-rendering', {
cause: error
});
wrappedError.digest = error.digest;
throw wrappedError;
} else {
throw error;
}
}
return locale;
}
const getLocaleFromHeader = cache(getLocaleFromHeaderImpl);
async function getRequestLocale() {
return getCachedRequestLocale() || (await getLocaleFromHeader());
}
export { getRequestLocale };