[英]What is the url with which I can access my expess app (nodejs)
我已经使用ssh访问权限在GoDaddy上部署了Nodejs Express应用,以配置整个过程。 但是我找不到将我引向应用程序的URL。
它在我通过链接http:// localhost:3000访问该应用程序的计算机上完美运行
const express = require("express");
const bodyParser = require("body-parser");
const httpRequest = require("request");
const app = new express();
const http = require("http").Server(app);
const io = require("socket.io")(http);
app.set("view engine","ejs");
var port = process.env.PORT || 3000;
app.use(express.static("public"));
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
//headers
app.use(function (req, res, next) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', '*');
// Request methods you wish to allow
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT,
PATCH, DELETE');
// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
// Set to true if you need the website to include cookies in the requests sent
// to the API (e.g. in case you use sessions)
res.setHeader('Access-Control-Allow-Credentials', true);
// Pass to next layer of middleware
next();
});
app.get("/",(request,response)=>{
response.send("hello world!");
});
http.listen(port,function(){
console.log(server.address());
console.log("listening on port "+port);
});
我拥有服务器的域名,我认为在服务器末尾添加“:3000”将使我可以访问该应用程序,但显然不能,我想知道如何访问它。
使用GoDaddy虚拟机的IP地址。 按照以下说明找到它:
Usege:
http://youripaddress:3000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.