如何使用Restify重定向到另一个页面?

时间:2018-12-20 13:22:24

标签: node.js restify

重新设置重定向不起作用

我有登录页面,当用户输入电子邮件和密码时。如果数据正确,则他应重定向到另一页。但这不起作用。

const restify = require('restify')

var server = restify.createServer()
server.listen(8080, function () {
    console.log('%s listening at %s', server.name, server.url)
});

server.post('/login/:email/:password', function (request, response, next) {
    const email = request.params.email
    const password = request.params.password

    if (authentication.credentialsIsCorrect(email, password)) {
        response.redirect('https://www.google.com', next)
        // response.redirect('/index.html', next)
        // response.redirect('localhost:8080/index.html', next)
        return
    }

})

没有异常错误。只是不重定向

1 个答案:

答案 0 :(得分:0)

成功状态为200后,可以从前端进行操作。