ECONNREFUSED with TRPC call on Vercel

Anyone run into this before? I just deployed my app to Vercel and I run into this error when I trigger a procedure. Everything works in dev but I'm sure I could be missing some change that's needed for a remote server.
5 Replies
Nick
Nick2y ago
That IP is localhost You need to configure the deployed code to point at the correct domains or IPs
xdxd#5555 / hanya
@nlucas Thanks, yeah that seems to be the problem, but any idea where in the code I need to change this?
Nick
Nick2y ago
This is something you set up on the client trpc setup most likely in the Link
xdxd#5555 / hanya
Guessing you mean these settings? I actually didn't touch them but I will try changing this up
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
}),

const getBaseUrl = () => {
if (typeof window !== "undefined") return ""; // browser should use relative url
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`; // SSR should use vercel url
return `http://localhost:${process.env.PORT ?? 3000}`; // dev SSR should use localhost
};
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
}),

const getBaseUrl = () => {
if (typeof window !== "undefined") return ""; // browser should use relative url
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`; // SSR should use vercel url
return `http://localhost:${process.env.PORT ?? 3000}`; // dev SSR should use localhost
};
Thanks for the help btw
Nick
Nick2y ago
yeah getBaseUrl will be the place to look Might just need to ensure VERCEL_URL is set