DangerZone
DangerZone
Explore posts from servers
TTCTheo's Typesafe Cult
Created by DangerZone on 6/27/2024 in #questions
Creaete T3 No Req or Res in TRPC context
@Sugan_Selvam Yes, but when I do this, I need req/res in order to find the auth, right?
8 replies
TTCTheo's Typesafe Cult
Created by DangerZone on 6/27/2024 in #questions
Creaete T3 No Req or Res in TRPC context
What am I doing wrong here?
8 replies
TTCTheo's Typesafe Cult
Created by DangerZone on 6/27/2024 in #questions
Creaete T3 No Req or Res in TRPC context
import "server-only";

import { headers } from "next/headers";
import { cache } from "react";

import { createCaller } from "~/server/api/root";
import { createTRPCContext } from "~/server/api/trpc";

/**
* This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when
* handling a tRPC call from a React Server Component.
*/
const createContext = cache(() => {
const heads = new Headers(headers());
heads.set("x-trpc-source", "rsc");

return createTRPCContext({
headers: heads,
});
});
import "server-only";

import { headers } from "next/headers";
import { cache } from "react";

import { createCaller } from "~/server/api/root";
import { createTRPCContext } from "~/server/api/trpc";

/**
* This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when
* handling a tRPC call from a React Server Component.
*/
const createContext = cache(() => {
const heads = new Headers(headers());
heads.set("x-trpc-source", "rsc");

return createTRPCContext({
headers: heads,
});
});
specifically here, there is no mention of req or res.
8 replies