sargsian
sargsian
TTCTheo's Typesafe Cult
Created by sargsian on 5/17/2023 in #questions
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 🙏
5 replies