apps/web: pass cookie to getConfig request

This commit is contained in:
vchikalkin 2024-02-22 10:52:26 +03:00
parent 4d5ab7fd36
commit dc1c315702
2 changed files with 13 additions and 3 deletions

View File

@ -4,10 +4,14 @@ import type { PageProps } from '@/types/page';
import { withError } from '@/utils/error'; import { withError } from '@/utils/error';
import { getPageUrlParams } from '@/utils/url'; import { getPageUrlParams } from '@/utils/url';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { headers } from 'next/headers';
export async function generateMetadata(pageProps: PageProps): Promise<Metadata> { export async function generateMetadata(pageProps: PageProps): Promise<Metadata> {
const pageUrlParams = getPageUrlParams(pageProps); const pageUrlParams = getPageUrlParams(pageProps);
const { title } = await apiIUS.getConfig({ pageUrlParams }); const headersList = headers();
const cookie = headersList.get('cookie') ?? '';
const { title } = await apiIUS.getConfig({ cookie, pageUrlParams });
const text = `Условия: ${title} | Эволюция`; const text = `Условия: ${title} | Эволюция`;
return { return {
@ -24,7 +28,10 @@ export default async function Page(pageProps: PageProps) {
return withError({ return withError({
render: async () => { render: async () => {
const pageUrlParams = getPageUrlParams(pageProps); const pageUrlParams = getPageUrlParams(pageProps);
const conditions = await apiIUS.getConditions({ pageUrlParams }); const headersList = headers();
const cookie = headersList.get('cookie') ?? '';
const conditions = await apiIUS.getConditions({ cookie, pageUrlParams });
return <Conditions html={conditions} />; return <Conditions html={conditions} />;
}, },

View File

@ -10,7 +10,10 @@ import { headers } from 'next/headers';
export async function generateMetadata(pageProps: PageProps): Promise<Metadata> { export async function generateMetadata(pageProps: PageProps): Promise<Metadata> {
const pageUrlParams = getPageUrlParams(pageProps); const pageUrlParams = getPageUrlParams(pageProps);
const { title } = await apiIUS.getConfig({ pageUrlParams }); const headersList = headers();
const cookie = headersList.get('cookie') ?? '';
const { title } = await apiIUS.getConfig({ cookie, pageUrlParams });
const text = `${title} | Эволюция`; const text = `${title} | Эволюция`;
return { return {