Resolve font file from node_modules in route handler
Unanswered
pjeweb posted this in #help-forum
pjewebOP
Is there a cleaner way to resolve the path to a file in node_modules (or somewhere else for that matter) from a deeply nested route handler (
src/app/api/og/[event]/[userName]/route.ts
)? Right now I have a bunch of ../
to get to the root of the project. const fontPtSansBold = await fetch(
new URL(
"../../../../../../node_modules/@fontsource/pt-sans/files/pt-sans-latin-700-normal.woff",
import.meta.url,
),
).then((res) => res.arrayBuffer());