[英]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.