How to fetch session from auth server

Hello!

I am loving better-auth so far, however, I am having one problem:
I have an auth server with the following auth files:
// lib/auth.ts (server)
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "~/server/db";
import { env } from "~/env";

const origins: string[] = [];

if (env.NODE_ENV === "development") {
  origins.push("http://localhost:3001");
}

export const auth = betterAuth({
  appName: "4uAuth",
  baseURL: env.BETTER_AUTH_BASE_URL,
  database: drizzleAdapter(db, { provider: "mysql" }),
  emailAndPassword: {
    enabled: true,
  },
  socialProviders: {
    google: {
      clientId: env.GOOGLE_CLIENT_ID,
      clientSecret: env.GOOGLE_CLIENT_SECRET,
    },
    linkedin: {
      clientId: env.LINKEDIN_CLIENT_ID,
      clientSecret: env.LINKEDIN_CLIENT_SECRET,
    },
    microsoft: {
      clientId: env.MICROSOFT_CLIENT_ID,
      clientSecret: env.MICROSOFT_CLIENT_SECRET,
    },
  },
  advanced: {
    crossSubDomainCookies: {
      enabled: true,
    },
  },
  trustedOrigins: origins,
});

// lib/client/auth.ts (client)
import { createAuthClient } from "better-auth/react";

export const authClient = createAuthClient();

How would I fetch a session from the server in a different application? When I attempt to do so, the endpoint goes through and everything works, however, the response is blank, versus when I hit the endpoint directly I get a response with the session. Is there something wrong with my server or application configuration? If so, how do I fix it? Thanks!
Was this page helpful?