diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index 6138801b..328c2e73 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -122,7 +122,7 @@ const parseUrl = (url) => { }; }; -const authOptions = (locale, req) => { +const authOptions = (locale, req, res) => { //console.log(req.query.callbackUrl); // let newURL = parseUrl( // locale == "cy" @@ -132,6 +132,21 @@ const authOptions = (locale, req) => { return { providers: [ + { + id: "emailAPI", + name: "emailAPI", + type: "email", + async sendVerificationRequest({ identifier: email, url }) { + const { host, port, protocol, token, searchParams } = + new URL(url); + console.log( + "============================================================\n", + "verification url API: " + url + "\n", + "============================================================\n" + ); + return res.status(200).json({ url: url }); + }, + }, EmailProvider({ maxAge: 10 * 60, // Magic links are valid for 10 min only async sendVerificationRequest({ identifier: email, url }) { @@ -143,7 +158,7 @@ const authOptions = (locale, req) => { const emailAddress = email; console.log( "============================================================\n", - "verificiation url: " + url + "\n", + "verification url: " + url + "\n", "============================================================\n" ); let newURL = @@ -236,5 +251,9 @@ export default (req, res) => { //console.log("----------", authOptions(req.cookies["pedw_locale"])); //console.log("----------", - return NextAuth(req, res, authOptions(req.cookies["pedw_locale"], req)); + return NextAuth( + req, + res, + authOptions(req.cookies["pedw_locale"], req, res) + ); };