AutumnA
Autumn5mo ago
26 replies
Amos

so basically something like this?

so basically something like this?
import { auth } from "@mypkg/auth";
import { autumnHandler } from "autumn-js/fastify";
import { fromNodeHeaders } from "better-auth/node";
import type { FastifyInstance } from "fastify";

export async function autumn(fastify: FastifyInstance) {
  fastify.route({
    handler: autumnHandler({
      identify: async (request) => {
        const { session, user } = (await auth.api.getSession({
          headers: fromNodeHeaders(request.headers),
        })) ?? { session: null, user: null };

        return {
          customerData: {
            email: user?.email,
            name: user?.name,
          },
          customerId: session?.activeOrganizationId?.toString(),
        };
      },
    }),
    method: ["GET", "POST"],
    url: "/autumn/*",
  });
}

or does the url have to be /api/autumn/*? if not, how does it work with the AutumnProvider on the frontend?
Was this page helpful?