How can i get the the params id in inside the metadata?
Answered
shadow posted this in #help-forum
shadowOP
Answered by Gazami crab
check dynamic metadata
https://nextjs.org/docs/app/building-your-application/optimizing/metadata#dynamic-metadata
https://nextjs.org/docs/app/building-your-application/optimizing/metadata#dynamic-metadata
25 Replies
@shadow Click to see attachment
Gazami crab
check dynamic metadata
https://nextjs.org/docs/app/building-your-application/optimizing/metadata#dynamic-metadata
https://nextjs.org/docs/app/building-your-application/optimizing/metadata#dynamic-metadata
Answer
@Gazami crab check dynamic metadata
https://nextjs.org/docs/app/building-your-application/optimizing/metadata#dynamic-metadata
shadowOP
thats what im trying but know im having another problem so if u can help me will be cool
TypeError: Failed to parse URL from /api/media/movie?id=933131
at getMovie (./lib/utils.ts:97:24)
at Module.generateMetadata (dashboard/movies/[id]/page.tsx:21:77)
digest: "3621837652"directly get the data in there
dont make uneccesary round trips
shadowOP
i did that because the api key keeps appering in the network requests
did you put it in .env?
shadowOP
yes
whats the name of the variable?
@aardani whats the name of the variable?
shadowOP
NEXT_PUBLIC_TMDB_API_KEY
remove
NEXT_PUBLIC_and it will make sure it wont be accidentally called in the client
@shadow thats what im trying but know im having another problem so if u can help me will be cool
TypeError: Failed to parse URL from /api/media/movie?id=933131
at getMovie (./lib/utils.ts:97:24)
at Module.generateMetadata (dashboard/movies/[id]/page.tsx:21:77)
digest: "3621837652"
Gazami crab
can you check this code?
const id = params.id;
const movie = await getMovie({ id });
const id = params.id;
const movie = await getMovie({ id });
@Gazami crab can you check this code?
const id = params.id;
const movie = await getMovie({ id });
shadowOP
dont work either im gonna try @aardani suggestion
@aardani dont fetch to your own server
this is an invalid fetch
probably i shouldnt make request in client components right
yeah
you shouldnt be getting that if you dont want to do the fetch in the client....
or use/expose the key in the client...
shadowOP
make the request in server componets and pass the data via props right
yeah
generateMetadata is a server function though and you just call the db method directly
since
its already in the server...