To configure cors, you need to use the cors plugin from hono/cors.
import { Hono } from "hono";import { auth } from "./auth";import { serve } from "@hono/node-server";import { cors } from "hono/cors";const app = new Hono();app.use( "/api/auth/*", // or replace with "*" to enable cors for all routes cors({ origin: "http://localhost:3001", // replace with your origin allowHeaders: ["Content-Type", "Authorization"], allowMethods: ["POST", "GET", "OPTIONS"], exposeHeaders: ["Content-Length"], maxAge: 600, credentials: true, }),);
By default, all Better Auth cookies are set with SameSite=Lax. If you need to use cookies across different domains, you’ll need to set SameSite=None and Secure=true. However, we recommend using subdomains whenever possible, as this allows you to keep SameSite=Lax. To enable cross-subdomain cookies, simply turn on crossSubDomainCookies in your auth config.
If you still need to set SameSite=None and Secure=true, you can adjust these attributes globally through cookieOptions in the createAuth configuration.