#Cannot parse action at /api/auth/session

16 messages · Page 1 of 1 (latest)

proven shore
#

Using Auth v5, and receiving this error:

    at parseActionAndProviderId (webpack-internal:///(rsc)/./node_modules/@auth/core/lib/utils/web.js:87:27)
    at toInternalRequest (webpack-internal:///(rsc)/./node_modules/@auth/core/lib/utils/web.js:32:40)
    at Auth (webpack-internal:///(rsc)/./node_modules/@auth/core/index.js:82:103)
    at httpHandler (webpack-internal:///(rsc)/./node_modules/next-auth/index.js:73:80)
    at eval (webpack-internal:///(rsc)/./node_modules/next/dist/esm/server/future/route-modules/app-route/module.js:220:43)
    at eval (webpack-internal:///(rsc)/./node_modules/next/dist/esm/server/lib/trace/tracer.js:96:36)
    at NoopContextManager.with (webpack-internal:///(rsc)/./node_modules/next/dist/compiled/@opentelemetry/api/index.js:361:30)
    at ContextAPI.with (webpack-internal:///(rsc)/./node_modules/next/dist/compiled/@opentelemetry/api/index.js:31:58)
    at NoopTracer.startActiveSpan (webpack-internal:///(rsc)/./node_modules/next/dist/compiled/@opentelemetry/api/index.js:954:34)
    at ProxyTracer.startActiveSpan (webpack-internal:///(rsc)/./node_modules/next/dist/compiled/@opentelemetry/api/index.js:994:36)```

It happens the moment I enter the website.

I'm totally stumped, the docs don't help too much, and I wouldn't even know what pieces of my code I need to share to debug this.
rough sunBOT
#

🔎 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)

proven shore
#

Heres my auth.ts:

import prisma from "@/db";
import NextAuth from "next-auth";
import authConfig from "./auth.config";

export const { handlers: { GET, POST }, auth } = NextAuth({
    pages: {
        signIn: '/'
    },
    session: {
        strategy: "jwt",
        maxAge: 2 * 24 * 60 * 60
    },
    callbacks: {
        async session({ session, token }) {
            session.user.id = token.sub;

            return session;
        },
        async signIn({ user, account, profile }) {
            if (account?.provider === "discord" && profile) {
                user.image = profile.avatar ? `https://cdn.discordapp.com/avatars/${profile.id}/${profile.avatar}.png` : `https://cdn.discordapp.com/embed/avatars/${Math.abs(Number(profile.id) >> 22) % 5}.png`

                return true;
            } else if (account?.provider === "roblox" && user) {
                const session = await auth();

                const existingAccount = await prisma.accounts.findUnique({
                    where: {
                        id: user.id as string,
                    },
                });

                if (existingAccount) return '/manage/accounts';

                const accounts = await prisma.accounts.findMany({
                    where: {
                        ownerId: session?.user.id
                    },
                })

                const isPrimary = accounts.length === 0;

                await prisma.accounts.create({
                    data: {
                        id: user.id as string,
                        ownerId: session?.user.id,
                        isPrimary: isPrimary
                    }
                })

                return '/manage/accounts';
            };

            return '/';
        },
    },
    ...authConfig
});```
#

And heres my auth.config.ts:

import DiscordProvider from "next-auth/providers/discord";
import { RobloxProvider } from "roblox-provider";

import type { NextAuthConfig } from "next-auth"

export default {
    providers: [
        DiscordProvider({
            clientId: process.env.DISCORD_CLIENT_ID as string,
            clientSecret: process.env.DISCORD_CLIENT_SECRET as string,
            authorization: { params: { scope: 'identify guilds' } },
        }),
        RobloxProvider({
            clientId: process.env.ROBLOX_ID as string,
            clientSecret: process.env.ROBLOX_SECRET as string,
            redirectUri: 'https://rolinker.net/auth',
            scopes: ["openid"],
        })
    ],
} satisfies NextAuthConfig```
#

Heres my api/auth/[...nextauth]/route.ts:

export { GET, POST } from "@/auth";
export const runtime = "edge";```
#

Note that auth.config.ts and auth.ts are both inside my src directory.

#

I do not use any middleware.

tame dome
#

did you solve this problem?

proven shore
#

No

#

I just posted it

clever dove
#

this is a known next-auth v5-beta.6+ bug

proven shore
#

Should I upgrade to beta 5?

clever dove
proven shore
#

I resolved the issue. I'm not exactly sure what I did, but I recall:
Making sure my NEXTAUTH_URL was correct in my .env
Removing my export const runtime = "edge";