Hosenur
Hosenur
Explore posts from servers
NNuxt
Created by Hosenur on 6/26/2024 in #❓・help
NuxtUI , keep Horizontal Nav Bar item active for multiple routes
In my case I want to keep it active for /react , /react/installation
2 replies
TTCTheo's Typesafe Cult
Created by Rafael Corrêa on 11/9/2023 in #questions
Set cookie within trpc
@shmookoff
26 replies
TTCTheo's Typesafe Cult
Created by Rafael Corrêa on 11/9/2023 in #questions
Set cookie within trpc
Here is the code for server/api/trpc.ts
import { initTRPC } from "@trpc/server";
import { type CreateNextContextOptions } from "@trpc/server/adapters/next";
import superjson from "superjson";
import { ZodError } from "zod";
import { db } from "~/server/db";
type CreateContextOptions = Record<string, never>;
const createInnerTRPCContext = (_opts: CreateContextOptions) => {
return {
db,
};
};
export const createTRPCContext = (_opts: CreateNextContextOptions) => {
return createInnerTRPCContext({});
};
const t = initTRPC.context<typeof createTRPCContext>().create({
transformer: superjson,
errorFormatter({ shape, error }) {
return {
...shape,
data: {
...shape.data,
zodError:
error.cause instanceof ZodError ? error.cause.flatten() : null,
},
};
},
});
export const createCallerFactory = t.createCallerFactory;
export const createTRPCRouter = t.router;
export const publicProcedure = t.procedure;
import { initTRPC } from "@trpc/server";
import { type CreateNextContextOptions } from "@trpc/server/adapters/next";
import superjson from "superjson";
import { ZodError } from "zod";
import { db } from "~/server/db";
type CreateContextOptions = Record<string, never>;
const createInnerTRPCContext = (_opts: CreateContextOptions) => {
return {
db,
};
};
export const createTRPCContext = (_opts: CreateNextContextOptions) => {
return createInnerTRPCContext({});
};
const t = initTRPC.context<typeof createTRPCContext>().create({
transformer: superjson,
errorFormatter({ shape, error }) {
return {
...shape,
data: {
...shape.data,
zodError:
error.cause instanceof ZodError ? error.cause.flatten() : null,
},
};
},
});
export const createCallerFactory = t.createCallerFactory;
export const createTRPCRouter = t.router;
export const publicProcedure = t.procedure;
26 replies
TTCTheo's Typesafe Cult
Created by Rafael Corrêa on 11/9/2023 in #questions
Set cookie within trpc
@shmookoff I am using pages router , and facing the same issue, httpBatchLink is also set, I get the error : tRPC failed on auth.register: cookies was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context
26 replies