📜  express js 重定向到 url - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:20.435000             🧑  作者: Mango

代码示例4
const app = require('express')();

// The `res.redirect()` function sends back an HTTP 302 by default.
// When an HTTP client receives a response with status 302, it will send
// an HTTP request to the URL in the response, in this case `/to`
app.get('/from', (req, res) => {
  res.redirect('/to');
});
app.get('/to', (req, res) => res.send('Hello, World!'));