Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

can singin with Email Provider by link in email when open in new tab #175

@mttzzz

Description

@mttzzz

Environment

  • Operating System: Windows_NT
  • Node Version: v20.7.0
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6
  • Package Manager: pnpm@8.15.6
  • Builder: -
  • User Config: devtools, app, build, modules, pinia, experimental, authJs, runtimeConfig
  • Runtime Modules: @unocss/nuxt@0.58.9, @bg-dev/nuxt-naiveui@1.12.2, @nuxt/content@2.12.1, @pinia/nuxt@0.5.1, @vueuse/nuxt@10.9.0, @hebilicious/authjs-nuxt@0.3.5
  • Build Modules: -

Reproduction

I use simple [...].ts

import EmailProvider from '@auth/core/providers/nodemailer'
import type { AuthConfig } from '@auth/core/types'
import { NuxtAuthHandler } from '#auth'
import prisma from '~/server/prisma/client'
import { CustomPrismaAdapter } from '~/server/prisma/custom-prisma-adapter'

const runtimeConfig = useRuntimeConfig()

// Refer to Auth.js docs for more details
export const authOptions: AuthConfig = {
  debug: true,
  basePath: '/api/auth',
  secret: runtimeConfig.authJs.secret,
  adapter: CustomPrismaAdapter(prisma),
  session: {
    strategy: 'database',
  },
  providers: [
    EmailProvider({
      server: {
        service: 'yandex',
        auth: {
          user: runtimeConfig.nodemailer.user,
          pass: runtimeConfig.nodemailer.password,
        },
      },
      from: runtimeConfig.nodemailer.from,
    }),
  ],
}

export default NuxtAuthHandler(authOptions, runtimeConfig)

When i go to http://localhost:3000/api/auth/signin and enter email i reveive email with link. If i copy this link and paste in the same browser tab -- everithing work. im authnethicated, but if i just clink on link and browser open new tab with this link. i receive

Unable to sign in
The sign in link is no longer valid.

It may have been used already or it may have expired.

and error in console

 ERROR  [auth][error] Verification: Read more at https://errors.authjs.dev#verification


 ERROR      at Module.callback (file:///C:/Users/kiril/projects/chatgpt.pushka.biz/node_modules/.pnpm/@auth+core@0.28.2_nodemailer@6.9.13/node_modules/@auth/core/lib/actions/callback/index.js:134:23)      
    at async AuthInternal (file:///C:/Users/kiril/projects/chatgpt.pushka.biz/node_modules/.pnpm/@auth+core@0.28.2_nodemailer@6.9.13/node_modules/@auth/core/lib/index.js:27:24)
    at async Auth (file:///C:/Users/kiril/projects/chatgpt.pushka.biz/node_modules/.pnpm/@auth+core@0.28.2_nodemailer@6.9.13/node_modules/@auth/core/index.js:109:34)
    at Object.handler (C:\Users\kiril\projects\chatgpt.pushka.biz\node_modules\.pnpm\@hebilicious+authjs-nuxt@0.3.5_@auth+core@0.28.2_nuxt@3.11.2\node_modules\@hebilicious\authjs-nuxt\dist\runtime\lib\server.mjs:23:22)
    at async file:///C:/Users/kiril/projects/chatgpt.pushka.biz/node_modules/.pnpm/h3@1.11.1/node_modules/h3/dist/index.mjs:1962:19
    at async Object.callAsync (file:///C:/Users/kiril/projects/chatgpt.pushka.biz/node_modules/.pnpm/unctx@2.3.1/node_modules/unctx/dist/index.mjs:72:16)
    at async Server.toNodeHandle (file:///C:/Users/kiril/projects/chatgpt.pushka.biz/node_modules/.pnpm/h3@1.11.1/node_modules/h3/dist/index.mjs:2249:7)

Describe the bug

Im litteraly mad. Please help! :)

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions