diff --git a/.changeset/lucky-parents-invent.md b/.changeset/lucky-parents-invent.md new file mode 100644 index 0000000000..99e678b28e --- /dev/null +++ b/.changeset/lucky-parents-invent.md @@ -0,0 +1,5 @@ +--- +"create-t3-app": patch +--- + +fix issue with prefetch protected procedure in auth templates diff --git a/cli/template/extras/src/app/page/with-auth-trpc-tw.tsx b/cli/template/extras/src/app/page/with-auth-trpc-tw.tsx index 49c9bbbe20..1d462b4441 100644 --- a/cli/template/extras/src/app/page/with-auth-trpc-tw.tsx +++ b/cli/template/extras/src/app/page/with-auth-trpc-tw.tsx @@ -8,7 +8,9 @@ export default async function Home() { const hello = await api.post.hello({ text: "from tRPC" }); const session = await getServerAuthSession(); - void api.post.getLatest.prefetch(); + if (session?.user) { + void api.post.getLatest.prefetch(); + } return ( diff --git a/cli/template/extras/src/app/page/with-auth-trpc.tsx b/cli/template/extras/src/app/page/with-auth-trpc.tsx index cfeed2f5b5..74cac168f9 100644 --- a/cli/template/extras/src/app/page/with-auth-trpc.tsx +++ b/cli/template/extras/src/app/page/with-auth-trpc.tsx @@ -9,7 +9,9 @@ export default async function Home() { const hello = await api.post.hello({ text: "from tRPC" }); const session = await getServerAuthSession(); - void api.post.getLatest.prefetch(); + if (session?.user) { + void api.post.getLatest.prefetch(); + } return (