[go: nahoru, domu]

Skip to content

Commit

Permalink
TRPC + TBA
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonXDev committed Mar 2, 2024
1 parent 4ed0e91 commit 093f70e
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions apps/nextjs/src/lib/utils/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@ function getBaseUrl() {
// browser should use relative path
return "";

if (process.env.VERCEL_URL)
// reference for vercel.com
return `https://${process.env.VERCEL_URL}`;
if (process.env.VERCEL_URL)
// reference for vercel.com
return `https://${process.env.VERCEL_URL}`;

if (process.env.RENDER_INTERNAL_HOSTNAME)
// reference for render.com
return `http://${process.env.RENDER_INTERNAL_HOSTNAME}:${process.env.PORT}`;
if (process.env.RENDER_INTERNAL_HOSTNAME)
// reference for render.com
return `http://${process.env.RENDER_INTERNAL_HOSTNAME}:${process.env.PORT}`;

// assume localhost
return `http://localhost:${process.env.PORT ?? 3000}`;
// assume localhost
return `http://localhost:${process.env.PORT ?? 3000}`;
}

export const trpc = createTRPCNext<AppRouter>({
Expand All @@ -34,18 +42,19 @@ export const trpc = createTRPCNext<AppRouter>({
**/
url: `${getBaseUrl()}/api/trpc`,

// You can pass any HTTP headers you wish here
async headers() {
return {
// authorization: getAuthCookie(),
};
},
}),
],
};
},
/**
* @link https://trpc.io/docs/v11/ssr
**/
ssr: false,
// You can pass any HTTP headers you wish here
async headers() {
return {
// authorization: getAuthCookie(),
};
},
}),
],
};
},
/**
* @link https://trpc.io/docs/v11/ssr
**/
ssr: false,
});

0 comments on commit 093f70e

Please sign in to comment.