Hono RPC not setting cookies on fetch

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}`,
  },
});


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.

What is a way around this?

github: https://github.com/jacobsamo/BuzzTrip/tree/improve-web
GitHub
Plan the trip you've always dreamed of. Contribute to jacobsamo/BuzzTrip development by creating an account on GitHub.
Was this page helpful?