fix: headers to v15

This commit is contained in:
Joel 2025-01-22 15:51:44 +08:00
parent f981eb4640
commit a465f092eb
2 changed files with 4 additions and 4 deletions

View File

@ -18,13 +18,13 @@ export type IGAProps = {
gaType: GaType
}
const GA: FC<IGAProps> = ({
const GA: FC<IGAProps> = async ({
gaType,
}) => {
if (IS_CE_EDITION)
return null
const nonce = process.env.NODE_ENV === 'production' ? headers().get('x-nonce') : ''
const nonce = process.env.NODE_ENV === 'production' ? (await headers()).get('x-nonce') : ''
return (
<>

View File

@ -41,8 +41,8 @@ export const getLocaleOnServer = async (): Promise<Locale> => {
if (!languages.length) {
// Negotiator expects plain object so we need to transform headers
const negotiatorHeaders: Record<string, string> = {}
headers().forEach((value, key) => (negotiatorHeaders[key] = value))
const negotiatorHeaders: Record<string, string> = {};
(await headers()).forEach((value, key) => (negotiatorHeaders[key] = value))
// Use negotiator and intl-localematcher to get best locale
languages = new Negotiator({ headers: negotiatorHeaders }).languages()
}