mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 15:35:35 +00:00
Add: tRPC + register on first time login
This commit is contained in:
21
utils/trpc.ts
Normal file
21
utils/trpc.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { httpBatchLink } from "@trpc/client";
|
||||
import { createTRPCNext } from "@trpc/next";
|
||||
import type { AppRouter } from "../server/routers/_app";
|
||||
|
||||
const getBaseUrl = () =>
|
||||
typeof window !== "undefined"
|
||||
? ""
|
||||
: `http://localhost:${process.env.PORT ?? 3000}`;
|
||||
|
||||
export const trpc = createTRPCNext<AppRouter>({
|
||||
config({ ctx }) {
|
||||
return {
|
||||
links: [
|
||||
httpBatchLink({
|
||||
url: `${getBaseUrl()}/api/trpc`,
|
||||
}),
|
||||
],
|
||||
};
|
||||
},
|
||||
ssr: false,
|
||||
});
|
||||
Reference in New Issue
Block a user