Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript User Authentication With Express and Mongo Sessions and Cookies Creating the Profile Route and Page

*[SOLVED]* 404 error on redirect to profile page.

This happens on both the login and sign ups. I have checked in the mongo shell, and the database is working, and contains the correct information that I enter on sign up. I have also verified that the session is being created correctly using the correct user id for when I log in.

I know I created the profile.pug file. When I tried it with redirect to '/about' I got the same error.

Not sure what to do...

Moderator marked as "solved" as per comment by OP

1 Answer

Found the solution. I forgot to add the / when defining the route. I wrote router.get('profile'....... instead of router.get('/profile....).

Figured I'd leave the answer up here rather than delete the question just in case anyone else made the same mistake.