Node.js Express在res.redirect()中失败
使用Express制作的API(它是一个大型API)正在生成我在重定向时不请求的内容。我有这条路线:Node.js Express在res.redirect()中失败,node.js,express,Node.js,Express,使用Express制作的API(它是一个大型API)正在生成我在重定向时不请求的内容。我有这条路线: router.get("/", ({ conn, query }, res) => { res.redirect('www.google.com'); } module.exports = router; 已进行重定向,但重定向到此URL:http://localhost:3000/www.google.com,当我需要它的时候 有什么问题吗?有CORS的东西吗?
router.get("/", ({ conn, query }, res) => {
res.redirect('www.google.com');
}
module.exports = router;
已进行重定向,但重定向到此URL:http://localhost:3000/www.google.com,当我需要它的时候
有什么问题吗?有CORS的东西吗?路由器()中的错误配置?
谢谢 您应该使用完整的URL:
res.redirect('https://www.google.com');
使用部分URL时,浏览器将其解释为相对URL,并尝试应用当前网页URL中缺少的URL部分