【发布时间】:2021-07-19 21:06:18
【问题描述】:
const express = require('express')
const app = express()
var open = require('open')
app.get('/', (req, res) => {
res.send('Hello World!')
open('https://google.com');
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(Example app listening at http://localhost:${PORT})
});
使用上面的代码。部署后我无法重定向到 google.com 并且它在 localhost 中工作
测试网址:https://redirecttestok.herokuapp.com/
请帮助我解决此问题或帮助我使用替代包。
【问题讨论】:
-
这不是在 Express 中重定向请求的方式。