AlexA
tRPC3y ago
7 replies
Alex

Running TRPC on Vercel with custom serialization fails

Hi all,
I'm having some difficulties with the serialization of my objects when I run on vercel.
I'm running nextjs 13.4.4 with trpc/server,client,next 10.28.1 and the next page routing.
I'm using a custom type "ts-money" which is returned in a trpc response like:
getSalaryEnvironment: protectedProcedure
    .input(
      z.object({
        administratorId: z.string(),
        salaryDate: salaryDateSchema,
      }),
    )
    .query(async ({ input }) => {
      return {
        date: new Date(2023, 5, 31),
        nbrOfDaysWorked: 20,
        salaryDate: input.salaryDate,
        totalGrossIncomeFromPreviousSalaryInYear: new Money(6000000,Currencies.EUR),
      }
    }),
Was this page helpful?