Deploying t3 on netlify?

I read the documentation regarding netlify deployment, but it seems there might be something missing, because just seting up netlify as in the docs doesn't work. Wont I need to somehow create netlify serverless functions that run the trpc procedures?
Solution:
ok seems to be a netlify issue, as even the repo from the docs doesn't work straigt out of the box and there is some reference error when accessing the server function. Instead of wasting more time with it I decided to use vercel instead. 🤷‍♂️...
Jump to solution
2 Replies
flowmotion
flowmotion6mo ago
apparently after changing the api.ts file to include a URL env parameter it works almost:
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
if (process.env.URL) return `https://${process.env.URL}`; // SSR should use netlify url
return `http://localhost:${process.env.PORT ?? 3000}`; // dev SSR should use localhost
};
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
if (process.env.URL) return `https://${process.env.URL}`; // SSR should use netlify url
return `http://localhost:${process.env.PORT ?? 3000}`; // dev SSR should use localhost
};
problem now is that netlify seems to use some common js export/require syntax when the package is setup to use esm syntax only.. not sure how to fix this though
Solution
flowmotion
flowmotion6mo ago
ok seems to be a netlify issue, as even the repo from the docs doesn't work straigt out of the box and there is some reference error when accessing the server function. Instead of wasting more time with it I decided to use vercel instead. 🤷‍♂️