简体   繁体   English

类型错误:response.redirect 不是 function

[英]TypeError: response.redirect is not a function

I need help...我需要帮助...

So, I have this code所以,我有这个代码

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")

But when I run it on the server I get the message:但是当我在服务器上运行它时,我收到了消息:

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)

Can anyone point out what I'm doing wrong?谁能指出我做错了什么?

Note: Running in localhost it goes normally注意:在 localhost 中运行正常

If you are trying to redirect to an external URL when someone goes to a specific URL on your site, try this:如果当有人访问您网站上的特定 URL 时,您尝试重定向到外部 URL,请尝试以下操作:

app.get("/course", (req, res) => {
  res.redirect("https://courseworkers.com");
});

My guess is, you are trying to call app_https_courseworkers(req, response) , but you aren't actually passing in a valid response object.我的猜测是,您正在尝试调用app_https_courseworkers(req, response) ,但实际上并没有传递有效的响应 object。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM