mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-22 16:00:37 +01:00
use trpc url options in api
This commit is contained in:
@@ -42,14 +42,14 @@ export function createTRPCHandler<Router extends AnyRouter>({
|
||||
createContext,
|
||||
responseMeta,
|
||||
onError,
|
||||
trpcURL,
|
||||
}: {
|
||||
router: Router
|
||||
createContext?: CreateContextFn<Router>
|
||||
responseMeta?: ResponseMetaFn<Router>
|
||||
onError?: OnErrorFn<Router>
|
||||
trpcURL: string
|
||||
}) {
|
||||
const url = '/api/trpc'
|
||||
|
||||
return defineEventHandler(async (event) => {
|
||||
const {
|
||||
req,
|
||||
@@ -68,7 +68,7 @@ export function createTRPCHandler<Router extends AnyRouter>({
|
||||
body: isMethod(event, 'GET') ? null : await useBody(event),
|
||||
query: $url.searchParams,
|
||||
},
|
||||
path: $url.pathname.substring(url.length + 1),
|
||||
path: $url.pathname.substring(trpcURL.length + 1),
|
||||
createContext: async () => createContext?.(event),
|
||||
responseMeta,
|
||||
onError: (o) => {
|
||||
|
||||
Reference in New Issue
Block a user