node.js - Redirecting client with NodeJS and Restify -


i'm building rest backend spa nodejs, restify , passportjs authentication. everything's working except last step, redirecting client backends /login/facebook/callback home page of application.

i've searched online , found lots of answers expressjs nothing useful node-restify yet. i've managed pick few snippets of code , i'm attempting @ moment:

app.get('/api/v1/login/facebook/cb', passport.authenticate('facebook', { scope: 'email' }), function(req, res) {     req.session.user = req.user._id;     res.header('location', '/#/home');     res.send(); }); 

the response sent location header not included , client presented white screen. how do proper redirect using node-restify api?

restify's response interface now has redirect method.

as of writing, there's test showing how use here.

the contents of test are:

server.get('/1', function (req, res, next) {     res.redirect('https://www.foo.com', next); }); 

many folks use restify more familiar expressjs. it's important understand (again, of writing) 1 of 3 main public api differences affecting porting of express plugins res.redirect method in restify requires pass next (or an internalerror thrown). i've ported several modules express restify , main api differences @ first (in restify):

  • server.use path & http-method-agnostic middleware
  • res.redirect requires pass next
  • some members or request interface methods rather values, such req.path. req.path alias of req.getpath in restify

i not saying under-the-hood similar, above 3 things main obstacles porting on express plugins. under-the-hood, restify has many advantages on express in experience using in both large enterprise applications , personal projects.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -