#https://next-auth.js.org/errors#client_fetch_error

21 messages · Page 1 of 1 (latest)

peak rune
#

This is my layout

'use client';

import './globals.css';
import "@fortawesome/fontawesome-svg-core/styles.css"; 
import { config } from "@fortawesome/fontawesome-svg-core";
import { ThemeProvider } from 'next-themes';
import Header from './components/header';
import Navigation from './components/navigation';
import { SessionProvider } from 'next-auth/react';
config.autoAddCss = false; 

export const metadata = {
  title: 'Next.js',
  description: 'Generated by Next.js',
}

export default async function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  
  return (
    <html lang="en">
        <body className="bg-main-bg text-gray-200">
          <SessionProvider>
            <ThemeProvider>
                <Navigation/>
                <Header/>
                <main>{children}</main>
            </ThemeProvider>
          </SessionProvider>
        </body>
    </html>
  );

}

Pretty new to next.js and I did follow the documentation but something must still be going wrong

lament finch
#

Ur nextauth route?

peak rune
# lament finch Ur nextauth route?
This is my app/api/auth/[...nextauth].ts
import NextAuth from 'next-auth';
import GithubProvider from "next-auth/providers/github"

const authOptions = {
  providers: [
    GithubProvider({
      clientId: process.env.GITHUB_CLIENT_ID as string,
      clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
    }),
  ],
  secret: process.env.NEXTAUTH_SECRET,
};

export default NextAuth(authOptions);

It was in app/api/auth/[...nextauth]/route.ts

But with bugfixing it I changed it to this file but the content is and was the saem

lament finch
#

This one is the correct one

peak rune
lament finch
#

So export as GET and POST

#

Well lets stick with that, it must be from other things

peak rune
#

Okay

#

Ill change it back

peak rune
#

app\api\auth[...nextauth]\route.ts

import GithubProvider from "next-auth/providers/github"
import NextAuth from "next-auth"

const handler = NextAuth({
    providers: [
        GithubProvider({
          clientId: process.env.GITHUB_CLIENT_ID as string,
          clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
        }),
      ],
      secret: process.env.NEXTAUTH_SECRET,
})

export { handler as GET, handler as POST }

lament finch
#

Did you set up NEXTAUTH_URL

peak rune
lament finch
#

Its wrong

#

Its supposed to be hostname /api/auth

#

Not just /

peak rune
#

Ah okay

lament finch
#

If you put /, your /app folder needs to have route.ts and ur NextAuth handler