migrate to app dir and ssr
This commit is contained in:
18
apps/web/src/app/api/trpc/[trpc]/route.ts
Normal file
18
apps/web/src/app/api/trpc/[trpc]/route.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { appRouter } from '@/server/api/root';
|
||||
import { getSession } from '@/server/auth';
|
||||
import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
|
||||
|
||||
const handler = (req: Request) =>
|
||||
fetchRequestHandler({
|
||||
endpoint: '/api/trpc',
|
||||
req,
|
||||
router: appRouter,
|
||||
createContext: async () => {
|
||||
const session = await getSession();
|
||||
return {
|
||||
session,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export { handler as GET, handler as POST };
|
||||
Reference in New Issue
Block a user