Wednesday, 7 June 2017

Cannot GET /app on VPS(works on localhost on mac)

recently I created an app with name app.js and a side folder named routes that contains a routes.js file, my app.js file has following code:

"use strict"; 
var express = require("express");
var bodyParser = require("body-parser");
var app = express();


app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

var routes = require("./routes/routes.js")(app);


var server = app.listen(8000, function () {
    console.log("Listening on port %s...", server.address().port);

});

and my routes/routes.js file has code like below:

"use strict"; 
var afterLoad = require('after-load');
var http = require('http');
let cheerio = require('cheerio');
var request = require('request');
var utf8 = require('utf8');
var youtubeSearch = require('youtube-search');
var fs = require('fs');
var youtubeDl = require('youtube-dl');
var ytdl = require('ytdl-core');

var appRouter = function (app) {

    app.get("./", function (req, res) {
        res.send("Hello World");
    });
}

module.exports = appRouter;

I was set my nginx proxy pass like this :

location /app {
        proxy_pass http://localhost:8000;
    }

but when I pm2 start app.js and send a GET request to my server on link: https://myserver.com/app ,I give following error:

Cannot GET /app

note that when I use all of this system on my local server on Mac it's ok and there is no problem with this



via Ali Moazenzadeh

No comments:

Post a Comment