Clarification needed for uploadthing middleware

I'm trying out uploadthing and am trying to integrate it with Clerk for authentication. In the docs (url: docs.uploadthing.com/concepts/auth-security#protecting-unauthenticated-users-from-uploading-files) it says: Protecting unauthenticated users from uploading files You can protect unauthenticated users from uploading files via the .middleware() function in each file route. Can anyone translate that for me please. I have one middleware.ts in the root direction - what is meant my 'each file route' does that mean I put a middleware.ts in the directory that contains my page.tsx (I'm using app not pages with t3 app and nextjs) Many thanks.
2 Replies
webdevkaleem
webdevkaleem4mo ago
each of your uploadthing route has multiple properties like .onUploadComplete or .middleware where u can write functions which will run accordingly in your case u should add your authentication logic in there (in .middleware)
No description
webdevkaleem
webdevkaleem4mo ago
note that these functions will run on your server imagine these as server actions but for your file uploads

Did you find this page helpful?