DelveroffD
Convex Community2y ago
54 replies
Delveroff

ConvexAuth+Next.js: should I implement `/api/sign-in`?

I try to set up ConvexAuth+Next.js.

When I call useAuthActions().signIn('resend', formData), I see that the request goes to my server's api/sign-in, which is 404.

I read here that this is the default value. However, the docs does not mention that I have to configure this route somehow. I thought this is handled by convexAuthMiddleware, but this isn't true.

I even tried to do the following, but without success:
import { ConvexAuthNextjsServerProvider } from '@convex-dev/auth/nextjs/server'
import type { PropsWithChildren } from 'react'

export function ConvexServerProvider({ children }: PropsWithChildren) {
  return (
    <ConvexAuthNextjsServerProvider
      apiRoute={`${process.env['NEXT_PUBLIC_CONVEX_URL']}/auth/sign-in`}
    >
      {children}
    </ConvexAuthNextjsServerProvider>
  )
}


Maybe I'm missing something but it's really unclear what to do with the api/sign-in route.

Also, I'm acknowledged that auth.js, especially next-auth, tells us to create these routes. But since Convex Auth docs doesn't mention it, I'm not sure if these two approaches will conflict.
Authentication library for your Convex backend
Was this page helpful?