Increase api file size limit on t3 stack

Im sending a image that exceeds 1mb file size limit of nextjs api route handler, and want to increase the limit. I have found posts that talk about it like this one https://github.com/trpc/trpc/discussions/2590, but can't figure out where to apply this when im using the t3 stack. here is my [trpc].ts where i see this post talking about : ' import { createNextApiHandler } from "@trpc/server/adapters/next"; import { env } from "../../../env.mjs"; import { appRouter } from "../../../server/api/root"; import { createTRPCContext } from "../../../server/api/trpc"; // export API handler export default createNextApiHandler({
router: appRouter, createContext: createTRPCContext, onError: env.NODE_ENV === "development" ? ({ path, error }) => { console.error( ❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message} ); } : undefined, }); '
GitHub
Body exceeded 1mb limit error in NextJS · trpc trpc · Discussion #2...
Provide environment information System: OS: macOS 12.5.1 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 233.28 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.7.0 - /usr/lo...
4 Replies
Sturlen
Sturlen5mo ago
File size is set in the FileRouter, usually under app/api/uploadthing/core.ts if you're following the example in the docs: https://docs.uploadthing.com/getting-started/appdir#creating-your-first-fileroute Your FileRouter should look like this. Set "maxFileSize" to what you need:
// FileRouter for your app, can contain multiple FileRoutes
export const ourFileRouter = {
// Define as many FileRoutes as you like, each with a unique routeSlug
imageUploader: f({ image: { maxFileSize: "4MB" } })
...
// FileRouter for your app, can contain multiple FileRoutes
export const ourFileRouter = {
// Define as many FileRoutes as you like, each with a unique routeSlug
imageUploader: f({ image: { maxFileSize: "4MB" } })
...
The issue you linked seems to be a tPRC specific issue with uploading large files directly to your server, which is different from what UploadThing does.
Next.js App Router Setup – uploadthing
Docs for the best file uploader to date
realmers
realmers5mo ago
Sorry i think there is a misunderstanding im sending a file from my client to a procedure that uploads that image to a storage bucket on supabase. The issue is that i cant send the file to my server because requests have file size limit.
Sturlen
Sturlen5mo ago
I totally misread that, my bad! Supabase seems to support presigned urls that let you upload directly from the client to supabase, without going through your route handler: https://supabase.com/docs/reference/javascript/storage-from-uploadtosignedurl
realmers
realmers5mo ago
I have got everything setup for sending the file to my serverside procedure, so I would love to continue with that for now. But thanks for the info. Im still looking for how to increase the file size limit. i found the solution to my problem which was to put 'export const config = { api: { bodyParser: false, }, }' in the same file as [trpc].ts along side everything else in the file
Want results from more Discord servers?
Add your server
More Posts
No background color for shadcn/ui components in T3 appI started working with a T3 app and couldn't get shadcn/ui styling to behave properly. The problem w`fetch` not working in Next.js API, the strangest issue I've encounteredI'm using t3 with pages router, and in one particular API call I'm trying to fetch a particular imag504 timeout for large data requesthave an api where i am fetching data with different timeframes. when i select the timeframe of "all Trpc useQuery keeps refetching even with no errors (I am getting back data every time)Hey everyone, I tried looking into why this might happen, and either dont know enough about it to deHow to configure Vitest in T3?Hello everyone, I'm currently working on implementing the Vitest example for TRPC as outlined in thUse of Next JS Server Actions in a projectHello everyone! would like to get your thoughts on this. I am working on a next js web app projecthow do I rate limit on nextjs api routes on app router?hey, currently using [Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/Keeping references to processes in nextjsHey, im trying the t3 stack and i have a quetions about nextjs in general. So the issue is that on Cannot update a component HotReload while rendering a differenet componentI try to call a server action from a client component, and I get this error for some reason anyone kUnderstanding serverside validation with zod and nextjs server actions???Hey y'all Im trying to implement zod into my validation for a form and i want to validate on a serve