Learning Tutrial Chapter 14, "authorized" in the callbacks configuration of NextAuth's auth.config.ts was not triggered. #85997
Replies: 2 comments
-
|
Hey @gaomigithub 👋 I ran into this same issue while following the Next.js Dashboard tutorial. The problem isn’t with your logic — it’s actually with how Next.js detects middleware. The How to fix itJust rename your file from: Keep everything else exactly the same: import NextAuth from "next-auth";
import { authConfig } from "./auth.config";
export default NextAuth(authConfig).auth;
export const config = {
matcher: ["/((?!api|_next/static|_next/image|.*\\.png$).*)"],
};Once you do that, Next.js will correctly recognize it as a middleware file, and your TipIf you’d rather keep the file named export { default } from './proxy'
export { config } from './proxy'That works too. So yeah, nothing’s wrong with your auth logic — it’s just a naming thing. Once the middleware is properly detected, your redirects will start working perfectly. |
Beta Was this translation helpful? Give feedback.
-
|
The reason your Once you rename
Dynamic routes and your config are all correct — it was purely a filename detection issue. After renaming, everything should behave exactly like in the tutorial. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hello guys,
I am currently learning about Next course from offical site and doing Chapter#14 (Adding Authentication). Other features such as "login" and "signout" learned from C#14 work good.
When I am testing what I did by learning at Protecting your routes with Next.js Proxy
This feels like nothing happened. I still can direct to any URL and not being redirected to login page.
Tried some search on Google and AI but they all tell me I did correct and should be work.... Also, I can not find the log I left inside authorized. I am really confused right now.
My repo
I pushed my codes wrote in this Chapter with commit name: "Chapter 14: Adding Authentication; todo: something wrong with authConfig".
Please give me any hint you find.
Thank you soooo much!!!
Additional information
Example
https://github.com/gaomigithub/nextjs-dashboard
Beta Was this translation helpful? Give feedback.
All reactions