export const adminsRpc = async () => {
const token = await getAccessToken();
const client = hc<typeof adminApp>(process.env.NEXT_PUBLIC_API_URL!, {
headers: {
Authorization: `Bearer ${token}`,
},
});
return client;
};
const getAccessToken = async () => {
const session = await fetchAuthSession();
if (!session.tokens) {
throw new Error("No session");
}
return session.tokens.accessToken.toString();
};
export const adminsRpc = async () => {
const token = await getAccessToken();
const client = hc<typeof adminApp>(process.env.NEXT_PUBLIC_API_URL!, {
headers: {
Authorization: `Bearer ${token}`,
},
});
return client;
};
const getAccessToken = async () => {
const session = await fetchAuthSession();
if (!session.tokens) {
throw new Error("No session");
}
return session.tokens.accessToken.toString();
};