\n \u003C/HydrateClient>\n );\n};\n\nexport default Page;\n```\nAll is working on local development is perfect. But when I try to build it-\n\n```\nError occurred prerendering page \"/unavailability\". Read more: https://nextjs.org/docs/messages/prerender-error\nTRPCClientError: Unauthorized request. Please login\n at s.from (/vercel/path0/.next/server/chunks/949.js:3:83107)\n at /vercel/path0/.next/server/chunks/949.js:3:89907\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\nExport encountered an error on /(dashboard)/unavailability/page: /unavailability, exiting the build.\n ⨯ Static worker exited with code: 1 and signal: null\n ELIFECYCLE Command failed with exit code 1.\nError: Command \"pnpm run build\" exited with 1\n\n```\n\n\nSo, it is natural that on build time, there is no authentications. But it stopping to build it-\n\n\n\n\n### Link to reproduction\n\nhttps://github.com/wegreet/dashboard-new-design\n\n### To reproduce\n\nJust build it with vercel\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[2902,2905],{"name":2903,"color":2904},"👻 invalid","e4e669",{"name":2906,"color":2907},"🐛 bug: unconfirmed","e99695",6441,"bug: TRPC with nextjs 15(App Router) production build failed!","2025-02-05T17:24:47Z","https://github.com/trpc/trpc/issues/6441",0.65556186,{"description":2914,"labels":2915,"number":2916,"owner":2857,"repository":2858,"state":2894,"title":2917,"updated_at":2918,"url":2919,"score":2920},"Hey Guys\r\n\r\nI've started using the T3 Stack with trpc / nextjs and wanted to use this awesome package to my Project.\r\nEverything works fine and I see the OpenAPI-Docs in the expected route. But i dont understand why this happens\r\n\r\nWhen looking at my trpc query, I have the following:\r\n```ts\r\nexport const exampleRouter = createRouter().query(\"hello\", {\r\n meta: { openapi: { enabled: true, method: \"GET\", path: \"/api/trpc/example.hello\" } },\r\n input: z.object({ name: z.string() }),\r\n output: z.object({ greeting: z.string() }),\r\n resolve: ({ input }) => {\r\n return { greeting: `Hello ${input.name}!` };\r\n },\r\n});\r\n```\r\nwhich generated the OpenAPI docs but when i try to execute it throught the UI it generates the URL like this:\r\n`http://0.0.0.0:3000/api/trpc/example.hello?name=asdf` which is of course not wrong. But when looking into the dev-tools on my page the request generated from trpc-client is generated like this:\r\n`http://localhost:3000/api/trpc/example.hello?batch=1&input={\"0\":{\"json\":{\"name\":\"jerome\"}}}`\r\n\r\nCan i change this behavior for the generation of the OpenAPI docs or how would you recommend trying to fix this?\r\n\r\nThanks in advanced\r\nJerome",[],149,"[Help wanted] T3 Stack and Queryparameters","2023-06-08T11:28:37Z","https://github.com/trpc/trpc-openapi/issues/149",0.6572921,{"description":2922,"labels":2923,"number":2924,"owner":2857,"repository":2857,"state":2894,"title":2925,"updated_at":2926,"url":2927,"score":2928},"Hi there ! thanks for the awesome lib !\r\n\r\nI have lost a bit of time the past couple of day so I'd figured I would share my story and my resolutions for the record.\r\n\r\nI have been deploying my trpc router in express in a serverless context, specifiically with `@vendia/serverless-express`. something like:\r\n\r\n```ts\r\n\r\nconst express = require(\"express\");\r\nimport * as trpcExpress from \"@trpc/server/adapters/express\";\r\nimport serverlessExpress from \"@vendia/serverless-express\";\r\nimport { router, inferAsyncReturnType } from \"@trpc/server\";\r\nimport { CreateExpressContextOptions } from \"@trpc/server/adapters/express\";\r\n\r\n// trpc router\r\nexport const createContext = ({\r\n req,\r\n res,\r\n}: CreateExpressContextOptions) => ({}); // no context\r\n\r\nexport type Context = inferAsyncReturnType\u003Ctypeof createContext>;\r\n\r\n// simplest router ever\r\nexport const appRouter = router\u003CContext>()\r\n .mutation(\"hello-mut\", {\r\n input: z.object({\r\n id: z.string(),\r\n }),\r\n resolve({ input }) {\r\n return { id: input.id };\r\n },\r\n });\r\n\r\nconst app = express();\r\n\r\napp.use(\r\n \"/trpc\",\r\n trpcExpress.createExpressMiddleware({\r\n router: appRouter,\r\n createContext: createContext,\r\n })\r\n);\r\n\r\nexport const handler = serverlessExpress({ app });\r\n\r\n```\r\n\r\nLocally when running project through the default express listener, everything is fine. but as I soon as I would deploy even the simplest of mutation in aws lambdas, I would get this error:\r\n\r\n```json\r\n[\r\n {\r\n \"id\":null,\r\n \"error\":{\r\n \"message\":\"[\\n {\\n \\\"code\\\": \\\"invalid_type\\\",\\n \\\"expected\\\": \\\"object\\\",\\n \\\"received\\\": \\\"number\\\",\\n \\\"path\\\": [],\\n \\\"message\\\": \\\"Expected object, received number\\\"\\n }\\n]\",\r\n \"code\":-32600,\r\n \"data\":{\r\n \"code\":\"BAD_REQUEST\",\r\n \"httpStatus\":400,\r\n \"stack\":\"TRPCError: [\\n {\\n \\\"code\\\": \\\"invalid_type\\\",\\n \\\"expected\\\": \\\"object\\\",\\n \\\"received\\\": \\\"number\\\",\\n \\\"path\\\": [],\\n \\\"message\\\": \\\"Expected object, received number\\\"\\n }\\n]\\n at Procedure.parseInput (/Users/tclain/z/p/apex/.sst/artifacts/dev-apex-api-nexus-core-api-Lambda_default/src/api/index.js:2881:17)\\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\\n at async /Users/tclain/z/p/apex/.sst/artifacts/dev-apex-api-nexus-core-api-Lambda_default/src/api/index.js:2891:25\\n ..... REST of call stack......\",\r\n \"path\":\"hello-mut\"\r\n }\r\n }\r\n }\r\n]\r\n```\r\n\r\nWait what 😱 ??\r\ni Have no number at all in my mutation but the error says it is received a number. When debugging this number was \"123\".\r\n\r\nSo I went into the rabbit hole and it turns out that the serverless handler parses `req.body` as a.... Buffer, not a string and it seems trpc expect a string.\r\n\r\nSo in `resolveHTTPResponse` instead of receiving:\r\n\r\n```\r\n{ [batchId]: JSON payload\r\n}\r\n```\r\n\r\nit receives:\r\n\r\n```\r\nSerialized Buffer\r\n```\r\n\r\nwith console logs in this file:\r\n```\r\nDEV bodyResult {\"0\":{\"id\":\"bla\"}}\r\nDEV - getInputs {\r\n '0': 123,\r\n '1': 34,\r\n '2': 48,\r\n '3': 34,\r\n '4': 58,\r\n '5': 123,\r\n '6': 34,\r\n '7': 105,\r\n '8': 100,\r\n '9': 34,\r\n '10': 58,\r\n '11': 34,\r\n '12': 98,\r\n '13': 108,\r\n '14': 97,\r\n '15': 34,\r\n '16': 125,\r\n '17': 125,\r\n readBigUInt64LE: [Function: readBigUInt64LE],\r\n readBigUInt64BE: [Function: readBigUInt64BE],\r\n readBigUint64LE: [Function: readBigUInt64LE],\r\n readBigUint64BE: [Function: readBigUInt64BE],\r\n readBigInt64LE: [Function: readBigInt64LE],\r\n readBigInt64BE: [Function: readBigInt64BE],\r\n writeBigUInt64LE: [Function: writeBigUInt64LE],\r\n writeBigUInt64BE: [Function: writeBigUInt64BE],\r\n ...... REST OF Buffer object,\r\n swap64: [Function: swap64],\r\n toLocaleString: [Function: toString]\r\n}\r\nDEV - getInput for each 123\r\nDEV number 123\r\nDEV t [ZodError]: [\r\n {\r\n \"code\": \"invalid_type\",\r\n \"expected\": \"object\",\r\n \"received\": \"number\",\r\n \"path\": [],\r\n \"message\": \"Expected object, received number\"\r\n }\r\n]\r\n```\r\nand so the batch \"0\" get the first value of the array like Buffer, here the number 123....\r\n\r\n\r\nSo at this point I was puzzled.\r\n\r\nWhat I have done right now to make it work is to create a small middleware that detects if the body is a buffer and replace it with the string version:\r\n\r\n```ts\r\napp.use((req, res, next) => {\r\n if (req.body && Buffer.isBuffer(req.body)) {\r\n req.body = req.body.toString();\r\n }\r\n next();\r\n});\r\n```\r\n\r\nHope that helps someone else... Would it be sensible to handle that in trpc ? I have noticed that the recommended approach is \"plug and play\" and it should just work ™️, so I guess this additional check could help.\r\n\r\n\r\n\r\n",[],1550,"Mutation fails when using express adapter in serverless scenario (request body is a buffer)","2022-02-22T14:35:07Z","https://github.com/trpc/trpc/issues/1550",0.6585652,{"description":2930,"labels":2931,"number":2935,"owner":2857,"repository":2857,"state":2894,"title":2936,"updated_at":2937,"url":2938,"score":2939},"### Describe the feature you'd like to request\n\nTo describe the needed feature, let's take the following problem:\r\n\r\n```ts\r\nconst res = await fetch(\"some-api-url\", { method: \"GET\" });\r\n\r\nif (!res.ok)\r\n throw new TRPCError({\r\n message: \"Failed to fetch the API\",\r\n code: res.status // Convert the `res.status` to Trpc Error Code Key\r\n });\r\n```\r\n\r\nHere, I'm trying to use the HTTP status code to set the TRPC error code, but unfortunately, I can't.\r\nThat's the needed feature: exposing more HTTP error resources that will allow us to convert the HTTP error status to the TRPC error code!\r\n\n\n### Describe the solution you'd like to see\n\nIt will be interesting to export the `JSONRPC2_TO_HTTP_CODE` from [getHTTPStatusCode.ts](https://github.com/trpc/trpc/blob/next/packages/server/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts#L6) and add it inverted equivalent `HTTP_CODE_TO_JSONRPC2`\r\n\r\nSo instead of this:\r\nhttps://github.com/trpc/trpc/blob/3388c9691d122b9d4047b2de0caedcdf611354ab/packages/server/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts#L6-L33\r\n\r\nWe could have\r\n```ts\r\nexport const JSONRPC2_TO_HTTP_CODE: Record\u003C\r\n keyof typeof TRPC_ERROR_CODES_BY_KEY,\r\n number\r\n> = {\r\n // Keys -> Values ...\r\n};\r\n\r\nexport const HTTP_CODE_TO_JSONRPC2: Invert\u003C\r\n typeof JSONRPC2_TO_HTTP_CODE\r\n> = {\r\n [400]: BAD_REQUEST,\r\n [401]: UNAUTHORIZED,\r\n [403]: FORBIDDEN,\r\n [404]: NOT_FOUND,\r\n [405]: METHOD_NOT_SUPPORTED,\r\n [408]: TIMEOUT,\r\n [409]: CONFLICT,\r\n [412]: PRECONDITION_FAILED,\r\n [413]: PAYLOAD_TOO_LARGE,\r\n [415]: UNSUPPORTED_MEDIA_TYPE,\r\n [422]: UNPROCESSABLE_CONTENT,\r\n [429]: TOO_MANY_REQUESTS,\r\n [499]: CLIENT_CLOSED_REQUEST,\r\n [500]: INTERNAL_SERVER_ERROR,\r\n [501]: NOT_IMPLEMENTED,\r\n [502]: BAD_GATEWAY,\r\n [503]: SERVICE_UNAVAILABLE,\r\n [504]: GATEWAY_TIMEOUT,\r\n}\r\n\r\nexport function getStatusCodeFromKey(code: keyof typeof TRPC_ERROR_CODES_BY_KEY) {\r\n return JSONRPC2_TO_HTTP_CODE[code] ?? 500;\r\n}\r\n```\r\n> A bit like what was done at [unstable-core-do-not-import/rpc/codes.ts#L53](https://github.com/trpc/trpc/blob/next/packages/server/src/unstable-core-do-not-import/rpc/codes.ts#L53)\n\n### Describe alternate solutions\n\n> No alternate solutions\n\n### Additional information\n\nI've done a decent minimum of research before creating this issue.\r\nIf there's a better solution or someone else has already created a similar issue I've not noticed, please let me know (and I'll probably close this one)\n\n### 👨👧👦 Contributing\n\n- [X] 🙋♂️ Yes, I'd be down to file a PR implementing this feature!",[2932],{"name":2933,"color":2934},"✅ accepted-PRs-welcome","0052cc",6137,"feat: expose more http error resources","2025-03-20T15:42:38Z","https://github.com/trpc/trpc/issues/6137",0.6590497,{"description":2941,"labels":2942,"number":2943,"owner":2857,"repository":2857,"state":2894,"title":2944,"updated_at":2945,"url":2946,"score":2947},"Hello 👋 First of all thank you so much for this amazing project, it's _awesome_ to use and we're adopting it for some of our public facing services as an alternative to GraphQL at utility-company scale\r\n\r\nQuestion about error handling best practices; the JSON-RPC spec includes the following description:\r\n\r\n> The error codes from and including -32768 to -32000 are reserved for pre-defined errors. Any code within this range, but not defined explicitly below is reserved for future use. The error codes are nearly the same as those suggested for XML-RPC at the following url: http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php\r\n\r\n> The remainder of the space is available for application defined errors.\r\n\r\nhttps://www.jsonrpc.org/specification#error_object\r\n\r\nHowever, TRPC errors appear limited to the subset defined in the spec:\r\n\r\n\r\n\r\nDoes this mean that best practices for error handling is to return them as a standard result of the request instead of as a special error thrown:\r\n\r\n```typescript\r\n// I.e. this\r\nreturn { error: \"CUSTOM_ERROR\" }; // This would also now be typed correctly on the client\r\n// Instead of this\r\nthrow new TRPCError({ code: \"CUSTOM_ERROR\" }); // This is a type error\r\n```\r\n\r\nOnce again, thank you so much for this amazing library!",[],631,"Error handling best practices","2022-10-05T00:09:30Z","https://github.com/trpc/trpc/issues/631",0.6594139,{"description":2949,"labels":2950,"number":2951,"owner":2857,"repository":2857,"state":2894,"title":2952,"updated_at":2953,"url":2954,"score":2955},"Hey, tRPC folks.\r\n\r\nLoved your work here enough to take tRPC to production.\r\n\r\nWe're having a pretty major issue with the following, though.\r\n\r\n```\r\n{\r\n path: undefined,\r\n ctx: undefined,\r\n type: 'unknown',\r\n input: undefined,\r\n shape: {\r\n message: 'Unexpected request method OPTIONS',\r\n code: -32005,\r\n data: { code: 'METHOD_NOT_SUPPORTED', httpStatus: 405 }\r\n },\r\n error: TRPCError: Unexpected request method OPTIONS\r\n at Object.resolveHTTPResponse (/app/apps/web/.next/server/chunks/7239.js:439:13)\r\n at Object.nodeHTTPRequestHandler (/app/apps/web/.next/server/chunks/7239.js:231:44)\r\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\r\n at async /app/apps/web/.next/server/chunks/7239.js:77:5\r\n at async Object.apiResolver (/app/node_modules/next/dist/server/api-utils/node.js:185:9)\r\n at async NextNodeServer.runApi (/app/node_modules/next/dist/server/next-server.js:395:9)\r\n at async Object.fn (/app/node_modules/next/dist/server/base-server.js:496:37)\r\n at async Router.execute (/app/node_modules/next/dist/server/router.js:226:36)\r\n at async NextNodeServer.run (/app/node_modules/next/dist/server/base-server.js:606:29)\r\n at async NextNodeServer.handleRequest (/app/node_modules/next/dist/server/base-server.js:321:20) {\r\n originalError: undefined,\r\n code: 'METHOD_NOT_SUPPORTED',\r\n [cause]: undefined\r\n }\r\n}\r\n```\r\n\r\nWe followed most convention in the nextjs-prisma starter. [Our repo can be found here](https://github.com/kittrgg/kittr). The only thing that I can think of that we did that isn't in the docs is we had to change the `[trpc].ts` right for a `[[...trpc]].ts` route for the NextJS catch-all.\r\n\r\nWe actually can't reproduce this ourselves in all honesty and we're looking for answers. Was hoping we aren't the first to run into this. We're thinking this looks a lot like a preflight CORS request and this is somewhat confirmed by our logs.\r\n\r\nWould appreciate any guidance if we've seen this coming from tRPC before. ",[],2094,"Unexpected request method OPTIONS","2022-07-05T17:08:28Z","https://github.com/trpc/trpc/issues/2094",0.6629073,["Reactive",2957],{},["Set"],["ShallowReactive",2960],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fy9SKT3I6qO40NHAvIP9ChA7u6GhF_fUuTmiSS4eWQW8":-1},"/trpc/trpc-openapi/258"]