uploadthing: [BUG]: getting error on using utapi.deleteFiles

hey, im getting “Missing UPLOADTHING_SECRET env variable.” when trying to delete file.

this is my code : export const deleteFiles = async (fileKey: string) => { await utapi.deleteFiles(fileKey); };

i checked the env variables and everything is fine, the upload works

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 19 (3 by maintainers)

Most upvoted comments

im calling it in a server component, i moved it to a client one and still got the same problem

It definitely won’t work in a client component, since it relies on environment variables that don’t exist on client. We intended it to be used either in a /api route, or in TRPC for example. It should also work in server actions, but given the current state of those, I don’t know that I would necessarily recommend them 😅