Node.js 如何从http://localhost/goog 用户可访问www.google.com

Node.js 如何从http://localhost/goog 用户可访问www.google.com,node.js,Node.js,我无法理解如何将用户从localhost重定向到。当用户访问http://localhost/goog(假设您使用的是Express),您可以尝试: app.get("/goog", (req, res) => { res.status(301).redirect("https://www.google.com"); });

我无法理解如何将用户从localhost重定向到。当用户访问
http://localhost/goog
(假设您使用的是
Express
),您可以尝试:

app.get("/goog", (req, res) => {
    res.status(301).redirect("https://www.google.com");
});