fix: headers to v15

chore/upgrade-next
Joel 1 year ago
parent f981eb4640
commit a465f092eb

@ -18,13 +18,13 @@ export type IGAProps = {
gaType: GaType gaType: GaType
} }
const GA: FC<IGAProps> = ({ const GA: FC<IGAProps> = async ({
gaType, gaType,
}) => { }) => {
if (IS_CE_EDITION) if (IS_CE_EDITION)
return null 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 ( return (
<> <>

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

Loading…
Cancel
Save