trpc prefetch fails when building app

tRPC fails to get the data when it is build the application as the tRPC server cannot run when building. Any thoughts on how to fix this issue?
export default async function Page() {
void api.catalyst.auth.state.prefetch();
// ...
}
export default async function Page() {
void api.catalyst.auth.state.prefetch();
// ...
}
Solution:
export const dynamic = "force-dynamic";
export const dynamic = "force-dynamic";
...
Jump to solution
3 Replies
DrizzyDrake
DrizzyDrakeOP6mo ago
I found this solution here:
DrizzyDrake
DrizzyDrakeOP6mo ago
tRPC fetch breaking when building Next project - Theo's Typesafe Cult
I'm testing out tRPC, and I've tried fetching some asynchronous data. This only happens during pnpm build, dev mode works completely fine. The fetch is prefetched in the page, and then actually fetched within the component. It always errors in this way when it gets to the static page generation step. ```bash a [TRPCClientError]: fetch fail...
Solution
DrizzyDrake
DrizzyDrake6mo ago
export const dynamic = "force-dynamic";
export const dynamic = "force-dynamic";

Did you find this page helpful?