When using the rpc client in nextjs, it doesn't include the headers for the request like a normal fetch does, this ends up leaving out items like cookies which is needed for authentication on the server.
import type { AppType } from "@buzztrip/api/src";import { env } from "env";import { hc } from "hono/client";export const apiClient = hc<AppType>(env.NEXT_PUBLIC_API_URL!, { headers: { Authorization: `Bearer ${env.NEXT_PUBLIC_API_SECRET_KEY}`, },});
import type { AppType } from "@buzztrip/api/src";import { env } from "env";import { hc } from "hono/client";export const apiClient = hc<AppType>(env.NEXT_PUBLIC_API_URL!, { headers: { Authorization: `Bearer ${env.NEXT_PUBLIC_API_SECRET_KEY}`, },});
Since i will mainly being using this API on the client side I have no way to pass in the cookies without passing it from the server which is not feasable.