T
tRPC

❓-help

middleware error with minimal-react example

Mmozzius3/18/2023
hello! I tried to use the minimal-react version, but I get an error - it says that 'middleware' does not exist on CreateHTTPHandlerOptions<...>. Am I doing something wrong or is it broken?
Nnlucas3/18/2023
You may need to upgrade your tRPC version, that feature was released quite recently We're doing quite frequent releases without breaking changes so you should be safe to just update to the latest 10.x version
Mmozzius3/20/2023
Yeah sorry wasn’t clear - I was trying to use the minimal-react example from the repo (aka I cloned the whole monorepo and tried to run the example) So it’s definitely v10 :)
Nnlucas3/20/2023
Got it, yes I would hope that’s on the latest version! 😝 Starting fine on my machine, make sure you do
pnpm install
pnpm build

cd examples/minimal-react
pnpm dev
pnpm install
pnpm build

cd examples/minimal-react
pnpm dev
(though I reserve the right for those first 2 steps to not be necessary)
Mmozzius3/20/2023
Yep works all fine on my work laptop, will have to wait until I get home to try again properly It was super strange though. Wasn’t saying cors wasn’t installed or anything, just refusing to believe that middleware was an option you could pass
Nnlucas3/20/2023
Make sure you pull the latest main. There might have been an issue when you tried it which is now fixed
Mmozzius3/21/2023
Got it working - not 100% sure what is was but I synced my fork and ran pnpm build and it's working. I think the issue might have been not running the build command in the root dir

Looking for more? Join the community!

Recommended Posts
how to use the same Zod validation both client and server's procedure inputWhen submitting forms, I need the same validation. How to reduce the repeated code?pipe/unstable_pipeI cant seem to find it? according to the docs I can chain middlewares using pipe in v10 but the featImplementation of bi-directional cursor-based paginationI'm looking at the [example](https://trpc.io/docs/useInfiniteQuery#example-react-component) for `useHow to ignore `input` validation and just pass in an object with interfaces?For my input I just want to pass in an interface rather than using a Zod schema. Either that or if sWhere can I add a query key?I tried to follow as in useQuery from Tanstack, but Typescript started complaining ```js api.promptsasync inside link next handler possible ?Hey everyone, Today I had to do a bit of refactor, and I'm wondering something. I had to turn a syntRPC doesn't support redirectI use tRPC & @trpc/server/adapters/express. procdure.query({ctx: { res }} => { res.redirect('xxHow to get external key other than INPUT from RESTFUL request?SSO callback my api like api/trpc/user.login?token=abcCannot read properties of undefined (reading 'createTRPCReact')I'm trying to use it in an Astro project. https://github.com/Industrial/test-astro-solid/blob/main/application/octet-stream responseIm refactoring my old backend to trpc so far it was a pleasure and fairly straight forward process ❤Discriminated union handleHow Do I handle Input type if its discriminated union?? ``` export const batchTasksRouter = createHit external APIs ...I'm new to tRPC, I need to hit an external API (OpenAI) directly from the client-side. Can I still uCannot get subscription event to fireRipping my hair out here trying to get Websockets working with tRPC and Next. Everything seems to bHow to get response type depending on the input params?Simple example of a normal JS function with generics: ``` const example = <T extends unknown>(paramshow to build tRPC and Prisma with express?I am using TSC as the official docs example does. But when I use paths in tsconfig.json, It does notHow to infer types from input?When I call my procedure from the client I send an array of strings as an input. How can I infer theHow to infer types of a queryCoinsider the example `const hello = trpc.hello.useQuery();` I would like to export the type we get Data Visualisation/Chartsis anyone using tRPC on data visualisation (say bar chart/line chart) in a scenario close to a bankitrpc + AWS Lambda (through cdk)Hi all, has anyone successfully integrated tRPC with AWS Lambda? My current stack is API Gateway + LIs it possible to narrow an output schema if the query optionally doesn't return all fields?I have a router procedure that has an input schema that has an optional `filter` that changes the sh