diff --git a/.changeset/famous-taxis-deny.md b/.changeset/famous-taxis-deny.md new file mode 100644 index 0000000..b4ceced --- /dev/null +++ b/.changeset/famous-taxis-deny.md @@ -0,0 +1,5 @@ +--- +"create-better-t-stack": patch +--- + +Update trpc endpoint path from '/api/trpc' to '/trpc' diff --git a/apps/cli/template/base/apps/web-next/src/utils/trpc.ts b/apps/cli/template/base/apps/web-next/src/utils/trpc.ts index c86a0fd..61bd7a9 100644 --- a/apps/cli/template/base/apps/web-next/src/utils/trpc.ts +++ b/apps/cli/template/base/apps/web-next/src/utils/trpc.ts @@ -22,7 +22,7 @@ export const queryClient = new QueryClient({ const trpcClient = createTRPCClient({ links: [ httpBatchLink({ - url: `${process.env.NEXT_PUBLIC_SERVER_URL}/api/trpc`, + url: `${process.env.NEXT_PUBLIC_SERVER_URL}/trpc`, }), ], }) diff --git a/apps/cli/template/with-auth/apps/web-next/src/utils/trpc.ts b/apps/cli/template/with-auth/apps/web-next/src/utils/trpc.ts index f90fb69..3e327a7 100644 --- a/apps/cli/template/with-auth/apps/web-next/src/utils/trpc.ts +++ b/apps/cli/template/with-auth/apps/web-next/src/utils/trpc.ts @@ -22,7 +22,7 @@ export const queryClient = new QueryClient({ const trpcClient = createTRPCClient({ links: [ httpBatchLink({ - url: `${process.env.NEXT_PUBLIC_SERVER_URL}/api/trpc`, + url: `${process.env.NEXT_PUBLIC_SERVER_URL}/trpc`, fetch(url, options) { return fetch(url, { ...options, diff --git a/apps/cli/template/with-next/apps/server/src/app/api/trpc/[trpc]/route.ts b/apps/cli/template/with-next/apps/server/src/app/trpc/[trpc]/route.ts similarity index 93% rename from apps/cli/template/with-next/apps/server/src/app/api/trpc/[trpc]/route.ts rename to apps/cli/template/with-next/apps/server/src/app/trpc/[trpc]/route.ts index 769cbeb..9efa291 100644 --- a/apps/cli/template/with-next/apps/server/src/app/api/trpc/[trpc]/route.ts +++ b/apps/cli/template/with-next/apps/server/src/app/trpc/[trpc]/route.ts @@ -5,7 +5,7 @@ import { NextRequest } from 'next/server'; function handler(req: NextRequest) { return fetchRequestHandler({ - endpoint: '/api/trpc', + endpoint: '/trpc', req, router: appRouter, createContext: () => createContext(req) diff --git a/apps/cli/template/with-next/apps/server/src/middleware.ts b/apps/cli/template/with-next/apps/server/src/middleware.ts index 5390371..dcf96fd 100644 --- a/apps/cli/template/with-next/apps/server/src/middleware.ts +++ b/apps/cli/template/with-next/apps/server/src/middleware.ts @@ -15,5 +15,5 @@ export function middleware() { } export const config = { - matcher: '/api/:path*', + matcher: '/:path*', }