Next.js Discord

Discord Forum

Nextauth unexpected token

Answered
Mike posted this in #help-forum
Open in Discord
Avatar
Hello, i got this error with nextauth.
My middleware.js is in the root folder
Image
Image
Answered by Ray
You should export GET and POST functions on app/api/auth/[…nextauth]/route.js
View full answer

7 Replies

Avatar
i also tried it with a [...nextauth] folder and a route.js inside
Avatar
Image
Avatar
@Mike Click to see attachment
Avatar
this is how my rootlayout looks
import { SessionProvider } from "next-auth/react";
import React, { ReactNode } from "react";

function Provider({ children }) {
  return <SessionProvider>{children}</SessionProvider>;
}

export default Provider;
This is my provider
Image
Avatar
@Mike Click to see attachment
Avatar
You should export GET and POST functions on app/api/auth/[…nextauth]/route.js
Answer
Avatar
I have done it thank you very much 🙂