Sienna
TTCTheo's Typesafe Cult
•Created by Sienna on 3/20/2025 in #questions
t3: accessing static files server side
I'm trying to use
fs.readFileSync
to read PDFs and font files (.ttf
) on the server (to dynamically build a PDF report in response to an API call), but I get ENOENT: no such file or directory
no matter what I do. Even when the static file is in the same directory as the code trying to access it, I can't seem to target it. I noticed that __dirname
targets /.next/server/app/api/trpc/[trpc]
rather than the server-side file system, so I haven't been able to use it to help solve this problem. I feel like I must be missing something obvious, but I haven't found the answer yet.4 replies