我必须从AWS Secrets Manager
获取值并将它们加载到next-auth
authOptions配置中。我有这样的实现:
export const buildAuthOptions = async () => {
const secrets: AuthSecrets = await getSecret(
'secret_name',
);
return {
providers: [
CognitoProvider({
clientId: secrets.cognitoClientId,
clientSecret: secrets.cognitoClientSecret,
issuer: secrets.cognitoDomain,
}),
],
secret: secrets.JWTSecret,
};
};
export const authOptions: NextAuthOptions = buildAuthOptions();
const handler: NextAuthOptions = NextAuth(authOptions);
export { handler as GET, handler as POST };
我从控制台得到的错误是
- error TypeError: options.providers is not iterable
从一个函数返回authOptions的最佳实践是什么?
1条答案
按热度按时间bvjveswy1#
here解释如下:你应该从接头人那里得到秘密。