Next.js Discord

Discord Forum

Expressjs + passport-local + Next.js 13(App folder)

Unanswered
Siamese posted this in #help-forum
Open in Discord
SiameseOP
Hey, folks, I'd like to ask for some help with something. I'm trying to set up authentication for my app using Next.js 13 (App folder) with the backend using Express.js + Passport-local.

I've already configured the Express and passport.js parts here, or at least I THINK I have, but I'm not sure how to implement this authentication on the Next.js side now.

My goal is to protect both the API routes and some pages of the application. If a user tries to access a specific path of the application without any valid session cookie, they should be redirected to the login path '/'.

But im not sure how to add this to my actual application. I've created a test app with 2 pages: one with a login form and another one with a basic profile screen. The idea is to always block access to the profile page unless the user is authenticated. Do you have any tips on what I should be thinking about or looking for? At least some guidance on the path I should follow here to achieve what I want?

0 Replies