first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
21
apps/web/modules/shared/lib/server.ts
Normal file
21
apps/web/modules/shared/lib/server.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import "server-only";
|
||||
import { createQueryClient } from "@shared/lib/query-client";
|
||||
|
||||
import type { AppRouter } from "@repo/api";
|
||||
import { getBaseUrl } from "@repo/utils";
|
||||
import { hc } from "hono/client";
|
||||
import { headers } from "next/headers";
|
||||
import { cache } from "react";
|
||||
|
||||
export const getServerQueryClient = cache(createQueryClient);
|
||||
|
||||
export const getServerApiClient = async () => {
|
||||
const headerObject = Object.fromEntries((await headers()).entries());
|
||||
|
||||
return hc<AppRouter>(getBaseUrl(), {
|
||||
init: {
|
||||
credentials: "include",
|
||||
headers: headerObject,
|
||||
},
|
||||
}).api;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue