NextJs Auth Implementation problem
Answered
Blanc de Hotot posted this in #help-forum
Blanc de HototOP
Hello guys, I was trying to block my routes unless the user us Authenticated, however im running into this problem where even if a user is not signed in they can still access the routes in this case i only have it set for '/overview'. I believe the authorized calledback is not being applied at all since I have a console.log there for debuggin but it's not going off on the console. I even tried renaming my file to
Ill also inlcuide some images of my code to get a better Idea "
middleware.js but that did not work. I am able to sign in as a user but route blocking is not working. Any guidance is helpful thank you.Ill also inlcuide some images of my code to get a better Idea "
Answered by Blanc de Hotot
Thanks, I looked around, and found out that I actually needed to put the proxy.js file inside
src/ now it works2 Replies
@Blanc de Hotot Hello guys, I was trying to block my routes unless the user us Authenticated, however im running into this problem where even if a user is not signed in they can still access the routes in this case i only have it set for '/overview'. I believe the authorized calledback is not being applied at all since I have a console.log there for debuggin but it's not going off on the console. I even tried renaming my file to `middleware.js` but that did not work. I am able to sign in as a user but route blocking is not working. Any guidance is helpful thank you.
Ill also inlcuide some images of my code to get a better Idea "
when checking the next-auth available callback handlers, there is no
authorized callback, that you want to use (see attached). To check if a specific user can access your dashboard, check inside your page.js:export default async function Page() {
const session = await getServerSession(authOptions)
if(!session)
return notFound();
return <p>This is your protected page</p>
}Blanc de HototOP
Thanks, I looked around, and found out that I actually needed to put the proxy.js file inside
src/ now it worksAnswer