fix(templates): await params/cookies properly (#8560)
This commit is contained in:
@@ -73,7 +73,8 @@ export default async function Page({ params: paramsPromise }: Args) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function generateMetadata({ params: { slug = 'home' } }): Promise<Metadata> {
|
export async function generateMetadata({ params: paramsPromise }): Promise<Metadata> {
|
||||||
|
const { slug = 'home' } = await paramsPromise
|
||||||
const page = await queryPageBySlug({
|
const page = await queryPageBySlug({
|
||||||
slug,
|
slug,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import { RootPage, generatePageMetadata } from '@payloadcms/next/views'
|
|||||||
import { importMap } from '../importMap'
|
import { importMap } from '../importMap'
|
||||||
|
|
||||||
type Args = {
|
type Args = {
|
||||||
params: {
|
params: Promise<{
|
||||||
segments: string[]
|
segments: string[]
|
||||||
}
|
}>
|
||||||
searchParams: {
|
searchParams: Promise<{
|
||||||
[key: string]: string | string[]
|
[key: string]: string | string[]
|
||||||
}
|
}>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
|
export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const getMeUser = async (args?: {
|
|||||||
user: User
|
user: User
|
||||||
}> => {
|
}> => {
|
||||||
const { nullUserRedirect, validUserRedirect } = args || {}
|
const { nullUserRedirect, validUserRedirect } = args || {}
|
||||||
const cookieStore = cookies()
|
const cookieStore = await cookies()
|
||||||
const token = cookieStore.get('payload-token')?.value
|
const token = cookieStore.get('payload-token')?.value
|
||||||
|
|
||||||
const meUserReq = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/api/users/me`, {
|
const meUserReq = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/api/users/me`, {
|
||||||
|
|||||||
Reference in New Issue
Block a user