Express not loading in URL
up vote
0
down vote
favorite
I currently have an express server I'm running based on the express tutorial.
Here is my code for server.js
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
the server.js file is in a directory on my server:
http://myurl.com/node-webshot/server.js
I start the server with: npm start
and get this:
> webshot@0.18.0 start /home/myurl/node-webshot
> node server.js
Example app listening on port 3000!
when I go to my url: http://myserver.com/node-webshot/
I see the directory listing only:

note "myserver.com" is just a fill in to path for working folder.
My expected result would be that when I go to the roof of the file where server.js is loaded that it would show the "Hello world". Not sure what I'm missing here.
node.js express
|
show 1 more comment
up vote
0
down vote
favorite
I currently have an express server I'm running based on the express tutorial.
Here is my code for server.js
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
the server.js file is in a directory on my server:
http://myurl.com/node-webshot/server.js
I start the server with: npm start
and get this:
> webshot@0.18.0 start /home/myurl/node-webshot
> node server.js
Example app listening on port 3000!
when I go to my url: http://myserver.com/node-webshot/
I see the directory listing only:

note "myserver.com" is just a fill in to path for working folder.
My expected result would be that when I go to the roof of the file where server.js is loaded that it would show the "Hello world". Not sure what I'm missing here.
node.js express
simply go to http://<serverName>:port/
– xan_z
Nov 7 at 18:56
Cannot GET /preview/productpreview/node-webshot @xan_z
– FabricioG
Nov 7 at 19:04
I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
– FabricioG
Nov 7 at 19:06
you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
– xan_z
Nov 7 at 19:11
Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
– FabricioG
Nov 7 at 19:46
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I currently have an express server I'm running based on the express tutorial.
Here is my code for server.js
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
the server.js file is in a directory on my server:
http://myurl.com/node-webshot/server.js
I start the server with: npm start
and get this:
> webshot@0.18.0 start /home/myurl/node-webshot
> node server.js
Example app listening on port 3000!
when I go to my url: http://myserver.com/node-webshot/
I see the directory listing only:

note "myserver.com" is just a fill in to path for working folder.
My expected result would be that when I go to the roof of the file where server.js is loaded that it would show the "Hello world". Not sure what I'm missing here.
node.js express
I currently have an express server I'm running based on the express tutorial.
Here is my code for server.js
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
the server.js file is in a directory on my server:
http://myurl.com/node-webshot/server.js
I start the server with: npm start
and get this:
> webshot@0.18.0 start /home/myurl/node-webshot
> node server.js
Example app listening on port 3000!
when I go to my url: http://myserver.com/node-webshot/
I see the directory listing only:

note "myserver.com" is just a fill in to path for working folder.
My expected result would be that when I go to the roof of the file where server.js is loaded that it would show the "Hello world". Not sure what I'm missing here.
node.js express
node.js express
asked Nov 7 at 18:52
FabricioG
316314
316314
simply go to http://<serverName>:port/
– xan_z
Nov 7 at 18:56
Cannot GET /preview/productpreview/node-webshot @xan_z
– FabricioG
Nov 7 at 19:04
I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
– FabricioG
Nov 7 at 19:06
you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
– xan_z
Nov 7 at 19:11
Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
– FabricioG
Nov 7 at 19:46
|
show 1 more comment
simply go to http://<serverName>:port/
– xan_z
Nov 7 at 18:56
Cannot GET /preview/productpreview/node-webshot @xan_z
– FabricioG
Nov 7 at 19:04
I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
– FabricioG
Nov 7 at 19:06
you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
– xan_z
Nov 7 at 19:11
Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
– FabricioG
Nov 7 at 19:46
simply go to http://<serverName>:port/
– xan_z
Nov 7 at 18:56
simply go to http://<serverName>:port/
– xan_z
Nov 7 at 18:56
Cannot GET /preview/productpreview/node-webshot @xan_z
– FabricioG
Nov 7 at 19:04
Cannot GET /preview/productpreview/node-webshot @xan_z
– FabricioG
Nov 7 at 19:04
I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
– FabricioG
Nov 7 at 19:06
I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
– FabricioG
Nov 7 at 19:06
you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
– xan_z
Nov 7 at 19:11
you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
– xan_z
Nov 7 at 19:11
Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
– FabricioG
Nov 7 at 19:46
Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
– FabricioG
Nov 7 at 19:46
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53195956%2fexpress-not-loading-in-url%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
simply go to http://<serverName>:port/
– xan_z
Nov 7 at 18:56
Cannot GET /preview/productpreview/node-webshot @xan_z
– FabricioG
Nov 7 at 19:04
I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
– FabricioG
Nov 7 at 19:06
you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
– xan_z
Nov 7 at 19:11
Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
– FabricioG
Nov 7 at 19:46