SSO Sign-in not working

I have a backend config like this, in a production auth.domain.com app

I have already created and registered OIDC provider and all that.

On my
localhost:3000
I am tring to login using the client, I have the OIDC and SSO client configured already.

Login code looks like this

signIn.sso({
callbackURL: "localhost"
// or email: "me@mail.com"
domain: auth.domain.com
})


The backend config looks like this

xport const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: "mysql",
  }),
  emailAndPassword: {
    enabled: true,
    autoSignIn: true,
    minPasswordLength: 8,
    requireEmailVerification: false,
},
 plugins: [
    organization({
      creatorRole: "owner",
      organizationLimit: 1,
      membershipLimit: 50,
      sendInvitationEmail: async (invite) => {
        await sendEmail({
          message: OrgInviteEmail({
            org: invite.organization.name,
            role: invite.role,
            name: invite.inviter.user.name,
            id: invite.id,
          }),
          subject: "Workwize Organisation Invite",
          to: invite.email,
        });
      },
    }),
    admin(),
    oidcProvider({
      loginPage: "/auth/sign-in",
      consentPage: "/authorization",
      scopes: ["read", "read+write"],
      metadata: {
        issuer: appConfig.app_domain,
        authorization_endpoint: "/api/auth/oauth2/authorize",
        token_endpoint: "/api/auth/oauth2/token",
      },
    }),
    sso(),
    nextCookies(),
  ],
  appName: "MyApp",
trustedOrigins: ["http://localhost:3000", "domain.com"]

}


Is there something I am missing?
Was this page helpful?