fix docker build

This commit is contained in:
KMKoushik
2025-03-18 21:51:38 +11:00
parent 0fc27d8d7e
commit 2ddafe26b2

View File

@@ -44,44 +44,48 @@ declare module "next-auth" {
* Auth providers * Auth providers
*/ */
const providers: Provider[] = []; function getProviders() {
const providers: Provider[] = [];
if (env.GITHUB_ID && env.GITHUB_SECRET) { if (env.GITHUB_ID && env.GITHUB_SECRET) {
providers.push( providers.push(
GitHubProvider({ GitHubProvider({
clientId: env.GITHUB_ID, clientId: env.GITHUB_ID,
clientSecret: env.GITHUB_SECRET, clientSecret: env.GITHUB_SECRET,
allowDangerousEmailAccountLinking: true, allowDangerousEmailAccountLinking: true,
}) })
); );
} }
if (env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET) { if (env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET) {
providers.push( providers.push(
GoogleProvider({ GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID, clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET, clientSecret: env.GOOGLE_CLIENT_SECRET,
allowDangerousEmailAccountLinking: true, allowDangerousEmailAccountLinking: true,
}) })
); );
} }
if (env.FROM_EMAIL) { if (env.FROM_EMAIL) {
providers.push( providers.push(
EmailProvider({ EmailProvider({
from: env.FROM_EMAIL, from: env.FROM_EMAIL,
async sendVerificationRequest({ identifier: email, url, token }) { async sendVerificationRequest({ identifier: email, url, token }) {
await sendSignUpEmail(email, token, url); await sendSignUpEmail(email, token, url);
}, },
async generateVerificationToken() { async generateVerificationToken() {
return Math.random().toString(36).substring(2, 7).toLowerCase(); return Math.random().toString(36).substring(2, 7).toLowerCase();
}, },
}) })
); );
} }
if (providers.length === 0) { if (providers.length === 0 && process.env.SKIP_ENV_VALIDATION !== "true") {
throw new Error("No auth providers found, need atleast one"); throw new Error("No auth providers found, need atleast one");
}
return providers;
} }
/** /**
@@ -116,7 +120,7 @@ export const authOptions: NextAuthOptions = {
} }
}, },
}, },
providers, providers: getProviders(),
}; };
/** /**