Node js application at root path

imowayushka

Registered
Jun 22, 2019
1
0
1
Jakarta
cPanel Access Level
Root Administrator
I have been trying to deploy a node js application following the method provided here.
But there is something misleading in that instruction:
it was mentioned that you can access the app at "http://example.com/nodejsapp" where actually you can access it anywhere under "http://example.com/*" so long as * is not blank or "#".

This is actually correct behavior since the app source code is supposed to respond to any request with the same response.
Code:
const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World! NodeJS \n');
});
Which is where the problem now lies, why do I get a redirect to /cgi-sys/defaultwebpage.cgi when only using "http://example.com/*" with blank path or "#"?

I would like to serve my node js application at the root path of my main domain. Is this possible at the moment?
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,903
2,226
363
cPanel Access Level
DataCenter Provider
Twitter
I would like to serve my node js application at the root path of my main domain. Is this possible at the moment?
Hello @imowayushka,

You can enter a single slash (/) for the Application URL field when registering an application in cPanel >> Application Manager. If this isn't working (or the application isn't loading in your web browser), please share the full reproduction steps to help us reproduce the issue internally.

Thank you.