Next.js Discord

Discord Forum

Cannot read file in dynamic opengraph-image

Unanswered
Savannah posted this in #help-forum
Open in Discord
Avatar
SavannahOP
Hello team
I have 2 opengraph-images.tsx, 1 is at the root and works well
The 2nd one is dynamic and has issues reading files.
In particular this file:
const fontDataRegular = await readFile(
    path.join(process.cwd(), "og", "Inter-Regular.ttf"),
  );

Seems that the "og" folder isnt present when on dynamic route.
Both opengraph-images.tsx use NodeJS runtime.
I am even console logging the process.cwd(), and while in the root one i see the "og", in the 2nd one (dynamic one) i don't see the og folder.

3 Replies

i am doing this, but in the dynamic route doesnt seem to work
Avatar
SavannahOP
Image