session null in nextjs route handler

I know auth and sessions is working because it I can log in and out with no problem. My server functions are able to get sessions but whenever I try and get the session from a route handler it's null

This same function is used throughout my app and works everywhere except route handlers

const session = await auth.api.getSession({
        headers: await headers(),
    });

    if (!session) {
        return {
            user: null,
            session: null,
        };
    }

    return {
        session: session.session,
        user: session.user,
    };
Was this page helpful?