Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js DirectAdmin(web控件cpanel):未找到节点JS Express应用程序-应用程序路由返回404_Node.js_Api_Cpanel_Shared Hosting_Directadmin - Fatal编程技术网

Node.js DirectAdmin(web控件cpanel):未找到节点JS Express应用程序-应用程序路由返回404

Node.js DirectAdmin(web控件cpanel):未找到节点JS Express应用程序-应用程序路由返回404,node.js,api,cpanel,shared-hosting,directadmin,Node.js,Api,Cpanel,Shared Hosting,Directadmin,我已经在我的DirectAdmin web面板上的Cpanelsetup Node.js app插件上安装了我的Nodejs应用程序 var http = require('http'); const express = require('express'); var app = express(); const bodyParser = require('body-parser'); const UserRoutes = require('./routes/user'); var server

我已经在我的DirectAdmin web面板上的Cpanelsetup Node.js app插件上安装了我的Nodejs应用程序

var http = require('http');
const express = require('express');
var app = express();
const bodyParser = require('body-parser');
const UserRoutes = require('./routes/user');
var server = http.createServer(app);
const path = require('path');
const cors = require('cors');
const passport = require('passport');
app.use(cors());
// Static file folder
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
app.use(passport.initialize());
app.use(passport.session());

app.use('/user', UserRoutes);
module.export = app;
server.listen();
我的索引文件正在运行,没有显示任何错误,但一旦我点击API路由,它就会返回我
无法获取/API/


提前感谢:)。

您没有任何用于
/api
路由的处理程序/中间件。 您应该定义:

app.use('/api',apirouts)

apiRoutes将成为一个中间件,路由到正确的控制器


此路由没有处理程序,因此express引擎返回404。

app.use('/user',UserRoutes);我在上面的代码中调用我的中间件。请仔细检查。您正在路由/user而不是/api。我需要路由为/user not/api您执行的请求路径是什么?您可能正在执行以/api开头的请求