Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
4 replies
sargsian

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}`);
      }


Here's how I tried to do it, but it only works on dev, as I previously mentioned.
Thanks 🙏
Was this page helpful?