♻️ Add env variable validation
This commit is contained in:
1 parent
18e0e2a8ff
commit
3990c1a4ad
12 files changed
+140
-25
No files matched your search
+3
-3
@@ -8,6 +8,7 @@ import { createTRPCProxyClient, httpBatchLink, loggerLink } from '@trpc/client';
|
||||
import { createTRPCNext } from '@trpc/next';
|
||||
import { type inferRouterInputs, type inferRouterOutputs } from '@trpc/server';
|
||||
import superjson from 'superjson';
|
||||
import { env } from '~/env';
|
||||
import { type RootRouter } from '~/server/api/root';
|
||||
|
||||
const getTrpcConfiguration = () => ({
|
||||
@@ -26,7 +27,7 @@ const getTrpcConfiguration = () => ({
|
||||
links: [
|
||||
loggerLink({
|
||||
enabled: (opts) =>
|
||||
process.env.NODE_ENV === 'development' ||
|
||||
env.NEXT_PUBLIC_NODE_ENV === 'development' ||
|
||||
(opts.direction === 'down' && opts.result instanceof Error),
|
||||
}),
|
||||
httpBatchLink({
|
||||
@@ -37,8 +38,7 @@ const getTrpcConfiguration = () => ({
|
||||
|
||||
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
|
||||
return `http://localhost:${env.NEXT_PUBLIC_PORT ?? 3000}`; // dev SSR should use localhost
|
||||
};
|
||||
|
||||
/** A set of type-safe react-query hooks for your tRPC API. */
|
||||
|
||||
Reference in new issue
Block a user