[英]Node.JS and Express res.redirect() not enabling new webpage
[英]How can I add query parameters to a node.js/express.js res.redirect function?
我正在尝试使用重定向用户到我的应用程序中的 Google 授权页面。 对于我的情况,我不能使用任何 Google API 模块。
我知道我可以这样格式化我的res.redirect()
函数:
res.redirect('https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar.readonly&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A3000%2Fauth&client_id=690512789525-g8dbv0s1jo80u5hvevptqapeqokq7ees.apps.googleusercontent.com&hl=en&from_login=1&as=-6cc9a02870d13e22&authuser=0')
但我更喜欢更简洁的东西,我可以将查询参数保存在一个对象中。 就像是:
res.redirect({
uri: 'https://accounts.google.com/o/oauth2/auth,
scope: 'https://............etc',
response_type: 'code',
[...etc...]
})
将我的每个查询参数作为对象中的属性值对。
关于如何做到这一点的任何想法?
认为你需要这样的东西url.format(urlObj)
: https : url.format(urlObj)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.