Advanced Node and Express - Create New Middleware

I cannot pass A Get request to /profile correctly redirects to / since we are not authenticated also I copied the later solution and also not work.
the code is here

1 Like

Comparing your code to my code for the same back end section, I think the problem lies here:

          .get(ensureAuthenticated, (req, res) => {
               res.render(process.cwd() + '/views/pug/profile', /*-->*/{username: req.user.username}/*<--*/);

Try console logging req.user.username and see what it logs and adjust based off that.

EDIT: this is a bad comparison, I don’t think the above is the case, i need to remix your project to investigate further

1 Like

So compared more code, but not sure what the problem is.

Here is my code from same series of challenges from glitch if you’d like to compare, but not sure what is causing the issue.!/advnodenexpressregs?path=routes.js:98:20

your code had gave same output.
and in

I’m having a similar issue with this problem. It successfully redirects, but the test still fails. Just replying to so I can bookmark this post in case someone figures it out.

1 Like

See the issue on Github. It looks like the way the test is implemented, after the page is redirected it is looking for the words “Home page” to be present in the HTML.

The directions for the problem do not clearly state that the pug template should be updated, or that the title should be changed from ‘hello’, to ‘Home page’.

The easiest way to fix this is to change the title value to Home Page in the render function for the index page. Otherwise it looks like your code should be fine to pass the test.


I have started new glitch and passed.

Did you do anything differently with your new Glitch?

I’m just curious because I’m running into issues with other challenges not passing when the functionality of the app is working.

No, I was surprised it work.

This worked for me thanks

starting a new glitch session did not work for me, but changing the the title value did solve the problem. Thanks @hagnerd!


Thanks, in the ‘/’ route, changing { title: ‘Home Page’ } worked for me, too.


Thanks, this worked for me.

  .get((req, res) => {
     res.render(process.cwd() + '/views/pug/index', {showLogin: true, title: 'Home Page ', message: 'Please login'});

Worked for me too,
Thanks a lot

change the title of index to homepage ,It works for me

1 Like

@hagnerd Thanks! Changing title to Home Page worked for me too.

1 Like

This did it for me. This is a problem with the challenge’s directions.


This worked for me. Where in the steps, it said to change the title to Home page

1 Like

This worked for me as well. Thanks

I was crazy struggled and finally I just changed the h1 text in index.pug and profile.pug
Is it normal ? I spendt a half day just for that :frowning: