Reading public folder on prod

Hey y'all! So I have a folder of images residing in /public, that I read from a trpc procedure, and render the contents of it on client. Everything works great in development, but obviously things work different on prod. So my question is, how can I access the /public folder on prod, when the project is hosted on vercel.
let filePath;
if (process.env.NODE_ENV === "development") {
filePath = path.join(
__dirname,
`../../../../../public/assets/portfolio/${input.type}`
);
} else {
filePath = path.join(__dirname, `/assets/portfolio/${input.type}`);
}
let filePath;
if (process.env.NODE_ENV === "development") {
filePath = path.join(
__dirname,
`../../../../../public/assets/portfolio/${input.type}`
);
} else {
filePath = path.join(__dirname, `/assets/portfolio/${input.type}`);
}
Here's how I tried to do it, but it only works on dev, as I previously mentioned. Thanks 🙏
2 Replies
Matvey
Matvey2y ago
fetch the files from process.env.VERCEL_URL + path
sargsian
sargsianOP2y ago
that solves my problem, but only partially haha. Will I be able to loop over the nested folders with this method? the trpc procedure throws error, but when I try to access a particular image it works
Want results from more Discord servers?
Add your server