#Next-Auth authenticated "auth" is always null, despite session existing

9 messages ยท Page 1 of 1 (latest)

ocean ruin
#

I'm following the tutorial for adding Auth (https://nextjs.org/learn/dashboard-app/adding-authentication) but my authenticated function always returns false even after logging in.

In other server components, I can log in and access the auth() method which returns the session normally.

import authConfig from '@/auth.config';

export default authConfig.auth;

export const config = {
  // https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
};```
My middleware is in /src and looks like this ^

Add authentication to protect your dashboard routes using NextAuth.js, Server Actions, and Middleware.

terse nexusBOT
#

๐Ÿ”Ž 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)

stable heron
#

i am no help but I am doing the tutorial too and have the same issue

ocean ruin
#

Good to know I'm not alone ๐Ÿ˜‚

ocean ruin
stable heron
ocean ruin
#

๐Ÿ˜„

#

glad we're getting closer!

uncut mist
#

@ocean ruin