Issue with support for Google Provider Authentication Across Multiple Subdomains in NextAuth v5 #12693
Unanswered
hereisabrams
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm currently implementing NextAuth v5 in my application and aiming to enable Google Provider authentication across multiple subdomains (like app.x.com app1.x.com app2.x.com always pointing to the same app
My auth.ts
`
import GoogleProvider from "next-auth/providers/google";
import { cert } from "firebase-admin/app";
import MicrosoftEntraID from "next-auth/providers/microsoft-entra-id";
import NextAuth, { NextAuthConfig } from "next-auth";
import { FirestoreAdapter } from "@auth/firebase-adapter";
import { GOOGLE_AUTH_SCOPES } from "@/utils/global/GlobalVariables";
const microsoftTenantId = "common";
export const { auth, handlers, signIn, signOut } = NextAuth((req) => {
const host =
req?.headers?.get("x-original-host") ||
req?.headers?.get("x-forwarded-host") ||
req?.headers?.get("host");
const proto =
req?.headers?.get("x-forwarded-proto") || (host.includes("localhost") ? "http" : "https");
const baseUrl =
${proto}://${host}
;const fullUrl = new URL(req?.url,
https://${req?.headers?.get("host")}
);console.log("Full URL:", fullUrl?.href);
console.log("baseUrl", baseUrl);
});
`
my route.ts
import { handlers } from "@/utils/lib/auth/Auth"; export const { GET, POST } = handlers;
With the current setup, authentication works correctly on a single subdomain using the AUTH_URL. However, when trying a different subdomain I am faced with this error on the url - /error?error=Configuration
Beta Was this translation helpful? Give feedback.
All reactions