嗨,我是Node js的初学者,我将自己的nodejs项目部署到Windows服务器“ wwwrot”文件夹中,以便与邮递员获得restapi并在移动应用程序中使用它。但是邮递员没有任何反应,我改变了3000端口,但是还没有工作。 此外,nodejs复写可在server上的localhost:3000 /中正常工作。 VPS服务器ip地址:例如194.4.147.282,服务器域例如:194.4.147.282:1928
server.js文件:
const express = require("express");
const bodyParser = require("body-parser");
const app = express();
// parse requests of content-type - application/json
app.use(bodyParser.json());
// parse requests of content-type - application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
// simple route
app.get("/", (req, res) => {
res.json({ message: "Welcome to GymMedia BackEnd" });
});
require("./app/routes/customer.routes.js")(app);
// set port, listen for requests
// there is no .env file
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});