#Error: Page "/api/auth/[...nextauth]" is missing "generateStaticParams()"

20 messages · Page 1 of 1 (latest)

full gladeBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

round edge
#

Hello, Show us your code in /api/auth/[...nextauth]/route.ts

bitter ice
#

you are using static export which doesn't support next-auth since next-auth requires a server

ocean zinc
#

next.config.js

/** @type {import('next').NextConfig} */
const MATRICULE = "x";
const nextConfig = {
  basePath: process.env.NODE_ENV === "production" ? `/~${MATRICULE}/APOD` : "",
  output: "export",
};

module.exports = nextConfig;
#

/api/auth/[...nextauth]/route.ts

import NextAuth from "next-auth";
import { authOptions } from "@/app/lib/auth";

const handler = NextAuth(authOptions);

export { handler as GET, handler as POST };

/lib/auth.ts

import axios from "axios";
import NextAuth, { AuthOptions } from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";

export const authOptions: AuthOptions = {
  providers: [
    CredentialsProvider({
      name: "Credentials",
      credentials: {
        email: { label: "email", type: "text" },
        password: { label: "password", type: "password" },
      },
      async authorize(credentials) {
        try {
          if (!credentials?.email || !credentials?.password) {
            return Promise.resolve(null);
          }
          const response = await axios.post(
            "https://x.x.x/user/signin",
            {
              email: credentials.email,
              password: credentials.password,
            }
          );

          if (response.status === 200) {
            const data = await response.data;
            return Promise.resolve({
              id: data.user.id,
              email: data.user.email,
              firstname: data.user.firstname,
              lastname: data.user.lastname,
              country: data.user.country,
              token: data.token,
            });
          } else {
            return Promise.resolve(null);
          }
        } catch (error) {
          console.error(error);
          return Promise.resolve(null);
        }
      },
    }),
  ],
  session: {
    strategy: "jwt",
  },
  debug: process.env.NODE_ENV === "development",
  callbacks: {
    async jwt({ token, user }) {
      return { ...token, ...user };
    },
    async session({ session, token }) {
      session.user = token as any;
      return session;
    },
  },
  secret: process.env.NEXTAUTH_SECRET,
};
ocean zinc
bitter ice
ocean zinc
bitter ice
#

all auth libraries require a server to parse and handle user requests

#

so if you want to implement auth with static export, your best bet would be client-side-based auth like firebase

ocean zinc
#

Unfortunately, I don't have the option of using vercel or another server.

bitter ice
#

a server is still needed but it's firebase who manages that server, not you

#

(alternatives include e.g. supabase)

ocean zinc
#

yeah ok, in my case, i can just interact with rest api and i can't access to db x))))

#

Thanks for response ! Have a nice day

bitter ice
#

good luck with the project

#

not being able to have a running node server or hosting elsewhere is a very strict restriction...