Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Express在res.redirect()中失败_Node.js_Express - Fatal编程技术网

Node.js Express在res.redirect()中失败

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的东西吗?

使用Express制作的API(它是一个大型API)正在生成我在重定向时不请求的内容。我有这条路线:

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部分