routing - I added one more route to express and all I get is 404 -- WHY? -


i have project working doing auth google, facebook, github, , gitlab. pass rememberme parameter increase lifetime of created token. added 1 small route piece /auth/google section handle parameter. 404!

before change have: (which works fine)

router.use('/auth', auth) 

and auth has:

router.use('/google', google) 

and google has:

    let router = express.router();      export let brememberme: boolean;      router       .get('/', passport.authenticate('google', {         failureredirect: '/signup',         scope: [           'https://www.googleapis.com/auth/userinfo.profile',           'https://www.googleapis.com/auth/userinfo.email'         ],         session: false,       }))        .get('/callback', passport.authenticate('google', {         failureredirect: '/signup',         session: false       }), auth.settokencookie)      export default router; 

then added:

      .get('/login/:rememberme',          (req, res, next) => {            brememberme = req.params.rememberme;           req.url = '/auth/google';         next();       }) 

and /auth/google/login/true returns 404 , never reaches route piece? why this. have fundamental misunderstanding of routing thanks!

  • before attempt, tried modify passport.authenticate('google', ... ) handle passed parameter, failed. , felt more compact change.

i still know why fails above. in end, did:

 router   .get('/login/:rememberme', (req, res, next) => {     brememberme = req.params.rememberme;     info(brememberme);     next();   }, passport.authenticate('github', {     scope: [ 'user:email', 'public_repo' ],     failureredirect: '/signup',     session: false   }))    .get('/callback', passport.authenticate('github', {     failureredirect: '/signup',     session: true   }), auth.settokencookie); 

which works , bit simpler , doesn't have route , may others. still why? first attempt fail??


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -