Lucia + T3, although can't set sessions

Same as title says,
I'd go to the context, and pass req and res:
export const createInnerTRPCContext = (opts: CreateContextOptions) => {
  return {
    headers: opts.headers,
    db,
    req: opts.req,
    res: opts.res,
  };
};

export const createTRPCContext = (opts: { req: NextRequest, res: NextResponse }) => {
  // Fetch stuff that depends on the request

  return createInnerTRPCContext({
    headers: opts.req.headers,
    req: opts.req,
    res: opts.res,
  });
};


Within the router, I'd try to set session, nothing happens, no cookies appear on client side:
export const userRouter = createTRPCRouter({
  create: publicProcedure
    .input(z.object({ email: z.string().min(1) }))
    .mutation(async ({ ctx, input }) => {
      const user: DatabaseUserAttributes = await auth.createUser({
        key: {
          providerId: "username",
          providerUserId: input.email,
          password: "hi",
        },
        attributes: {},
      });
      const session: { sessionId: string } = await auth.createSession({
        userId: user.userId,
        attributes: {},
      });
      const authRequest = auth.handleRequest(ctx.req.method, context);
      authRequest.setSession(session);
    }),
});

Any ideas?
Was this page helpful?