feat(WEB-127): add trpc to handle requests both serverside and clientside
This commit is contained in:
15
app/api/trpc/[trpc]/route.ts
Normal file
15
app/api/trpc/[trpc]/route.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { fetchRequestHandler } from "@trpc/server/adapters/fetch"
|
||||
|
||||
import { appRouter } from "@/server"
|
||||
import { createContext } from "@/server/context"
|
||||
|
||||
async function handler(req: Request) {
|
||||
return fetchRequestHandler({
|
||||
createContext,
|
||||
endpoint: "/api/trpc",
|
||||
req,
|
||||
router: appRouter,
|
||||
})
|
||||
}
|
||||
|
||||
export { handler as GET, handler as POST }
|
||||
Reference in New Issue
Block a user