metadata being weird in prod
Answered
Britannia Petite posted this in #help-forum
Britannia PetiteOP
hi chat. my metadata in dev works fine but on the server it changes a param letter casing causing the metadata to fail on db lookup.
see below:
dev env logs:
prod env logs:
metadata code:
page route:
see below:
dev env logs:
{ postid: '102' }
GENERATING METADATA WITH POST ID 102
METADATA GENERATOR 102
METADATA CONFIRMED
prod env logs:
{ postId: '102' }
GENERATING METADATA WITH POST ID undefined
⨯ TypeError: Cannot read properties of undefined (reading 'id')
at Module.l (.next/server/app/robook/[postId]/page.js:2:312207) {
digest: '1490537656'
}
metadata code:
export async function generateMetadata(
{ params }: Props,
parent: ResolvingMetadata,
): Promise<Metadata> {
const { postid } = await params;
console.log(await params)
console.log("GENERATING METADATA WITH POST ID", postid)
const Post = await GetPost({ id: parseInt(postid) });
console.log("METADATA GENERATOR", Post.id)
if (!Post) return {};
console.log("METADATA CONFIRMED")
const postTitle = `${Post.user.name} (${Post.user.email})`;
const postDescription = Post.content.substring(0, 150);
const postImage = Post?.profile?.profilePicture || Post.user.image;
return {
title: postTitle,
description: postDescription,
openGraph: {
title: postTitle,
description: postDescription,
//images: [postImage],
url: `https://urlblahblahblah.com/robook/${postid}`,
},
twitter: {
card: "summary_large_image",
title: postTitle,
description: postDescription,
//images: [postImage],
},
};
}
page route:
/posts/[postid]/page.tsx
Answered by joulev
my guess is, you did a case-only rename on your local computer, but it's not reflected by git due to [file system case sensitivity of your OS](https://stackoverflow.com/questions/10523849/how-do-you-change-the-capitalization-of-filenames-in-git), so the rename never reaches the production build
7 Replies
Britannia PetiteOP
anyone know why its postid on dev and postId on prod? thats really odd considering the route for the page hasnt changed
Britannia PetiteOP
i dont remember doing that but i could of changed the casing accidently
my guess is, you did a case-only rename on your local computer, but it's not reflected by git due to [file system case sensitivity of your OS](https://stackoverflow.com/questions/10523849/how-do-you-change-the-capitalization-of-filenames-in-git), so the rename never reaches the production build
Answer
check the file name on the git repository where you push the code to
Britannia PetiteOP
ah got it
thanks for the help :d