I am trying to deploy a node app from a local to production environment.
On my local environment my code looked likes the code below and all works perfectly. Navigate to localhost:3000
, click login, and you are brought to the login
route.
LOCAL app.js file
var express = require('express');
var bodyParser = require("body-parser");
var app = express();
app.use(express.static(__dirname + '/public'))
.use(bodyParser());
app.get('/login', function(req, res) {
res.send('log me in!');
});
console.log('Listening on 3000');
app.listen(3000);
I have then uploaded to a server and am running the app.js
file using forever
- i.e. forever start app.js
. I can navigate to the homepage which is the index.html
file in the public
folder. The url looks like this - http://162.xx.xxx.xxx/project/public/
My app.js
file looks the same as above apart from this line:
app.get('http://162.xx.xxx.xxx/project/public/login', function(req, res) {
res.send('log me in!');
});
when i try and navigate to the login url it says:
The requested URL /project/login was not found on this server. Apache Server at http://162..*.*** Port 80
Can anyone advise what I am doing wrong?