goochy13 Posted May 17, 2020 Posted May 17, 2020 I am trying to run a simple node app using express; however, I keep getting "Cannot GET /test" when I try to access the app (goochy13.heliohost.org/test).I have followed the Node tutorial on the Wiki and managed to get it working using "http" - but as I cannot get the same app to work using express instead of http I can only assume express is the problem.My simple test app is below. var express = require("express"); app = express(); const hostname = '127.0.0.1'; const port = 3000; app.get("/", (req, res) =>{ res.statusCode = 200; res.setHeader('Content-Type', 'text/html'); res.end('Node.js is on and working.'); }); app.listen(port, hostname, () => { console.log("Test app is running."); }); I have copied across the "node_modules" folder as a .zip - and extracted it from the server side. I have also included package.json and I hit "ensure dependencies" in the application manager. Certainly possible that I've missed a step or misunderstand what is required to get this up and running. Anyone got any ideas? Cheers
Krydos Posted May 18, 2020 Posted May 18, 2020 Perhaps this will help? https://stackoverflow.com/questions/13339695/nodejs-w-express-error-cannot-get
goochy13 Posted May 19, 2020 Author Posted May 19, 2020 Perhaps this will help? https://stackoverflow.com/questions/13339695/nodejs-w-express-error-cannot-get I had a good read of this but still couldn't solve my problem. I can run the app on Localhost and it even works fine on Heroku, just not on Heliohost.
Krydos Posted May 20, 2020 Posted May 20, 2020 I tried this out on my Tommy account and I got the same result as you. The problem is express apparently does not like being in a subdirectory. As soon as I created a subdomain for it, it started working perfectly. https://express.krydos.heliohost.org/ You'll need to create a subdomain for it, or put it on the webroot of either your main domain or an alias or an addon domain. Ghost, which is another cranky node.js thing, hates being in a subdirectory as well. Here's my app.js var express = require('express') var app = express() app.get('/', function (req, res) { res.send('Express is working on HelioHost!'); }) var server = app.listen(3000, function () { var host = server.address().address var port = server.address().port console.log('Example app listening at http://%s:%s', host, port) })
goochy13 Posted May 24, 2020 Author Posted May 24, 2020 I tried this out on my Tommy account and I got the same result as you. The problem is express apparently does not like being in a subdirectory. As soon as I created a subdomain for it, it started working perfectly. https://express.krydos.heliohost.org/ You'll need to create a subdomain for it, or put it on the webroot of either your main domain or an alias or an addon domain. Ghost, which is another cranky node.js thing, hates being in a subdirectory as well. Here's my app.js var express = require('express') var app = express() app.get('/', function (req, res) { res.send('Express is working on HelioHost!'); }) var server = app.listen(3000, function () { var host = server.address().address var port = server.address().port console.log('Example app listening at http://%s:%s', host, port) }) Makes sense! Thanks a lot!
olstouna Posted April 10, 2021 Posted April 10, 2021 (edited) I tried this out on my Tommy account and I got the same result as you. The problem is express apparently does not like being in a subdirectory. As soon as I created a subdomain for it, it started working perfectly. https://express.krydos.heliohost.org/ You'll need to create a subdomain for it, or put it on the webroot of either your main domain or an alias or an addon domain. Ghost, which is another cranky node.js thing, hates being in a subdirectory as well. Here's my app.js var express = require('express') var app = express() app.get('/', function (req, res) { res.send('Express is working on HelioHost!'); }) var server = app.listen(3000, function () { var host = server.address().address var port = server.address().port console.log('Example app listening at http://%s:%s', host, port) }) I tried to deploy this app under http://alexa.stasauskas.lt/ and succeeded. But it seems that from https://alexa.stasauskas.lt/ (note its HTTPS, not HTTP) it just shows directory listing. Any particular steps I should do for it to be accessible from https under the same subdomain? Update: so apparently after night it works. Not sure why, maybe fixed automagically? Edited April 12, 2021 by olstouna
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now