Next Auth Session

I want to use useSession() I want the callback to do a check on the url it is coming from (req.headers.host is ideal); however, I cannot access this information in the callback function.

A possible solution I have explored is to go to /api/auth/[...nextauth].ts and override it from there however the problem with this is that whenever I am making trpc requests I have to also manually override that one which makes me repeat unnecessary code. I was just wondering if there is a better way to go about this.

The part of the code I am referring to for the callbacks is the following:
export const authOptions: NextAuthOptions = {
  callbacks: {
    session: ({ session, user }) => ({
      // Ideally make this a function that can access the request
      ...session,
      user: {
        ...session.user,
        id: user.id,
      },
    }),
  },


Thank you in advance.
Was this page helpful?