我需要帮助...
所以,我有此代码
var express = require('express');
var app = express();
//Sites
// Landingpage CourseWorkers ----------------------------------------
app_courseworkers = require('./sites/app')
app_https_courseworkers = (req, response) => response.redirect("https://courseworkers.com")
但是当我在服务器上运行它时,会收到消息:
0|index | TypeError: response.redirect is not a function
0|index | at Object.app_https_courseworkers [as handler] (/var/www/html/courseworkers/index.js:9:55)
0|index | at Server.overallHandler (/var/www/html/courseworkers/node_modules/vhttps/lib/init.js:103:25)
0|index | at emitTwo (events.js:126:13)
0|index | at Server.emit (events.js:214:7)
0|index | at parserOnIncoming (_http_server.js:619:12)
0|index | at HTTPParser.parserOnHeadersComplete (_http_common.js:115:23)
谁能指出我做错了什么?
注意:在localhost中运行正常
答案 0 :(得分:1)
如果当有人访问您网站上的特定URL时您尝试重定向到外部URL,请尝试以下操作:
app.get("/course", (req, res) => {
res.redirect("https://courseworkers.com");
});
我的猜测是,您正在尝试调用app_https_courseworkers(req, response)
,但实际上并没有传递有效的响应对象。