0

Hi have a NodeJs app in a shared hosting, where I'm trying to make API calls. Lets say my domain is example.com.

'http://localhost:' + global.PORT_SERVER + url + id

This works in local, because localhost is my machine; but in the server, as it's a shared hosting, the hostname is not my domain, but hl358.hostingexample.com.

$ hostname
$ hl358.hostingexample.com

Now with CURL from ssh, this works:

curl -i -H "Accept: application/json" "http://example.com:80/api/projects"

and this don't:

curl -i -H "Accept: application/json" "http://localhost:80/api/projects"

If I try to retrieve mydomain.com from node 'os' I still get hl318.hostingexample.com:

$ node
> const os = require('os')
> os.hostname()
'hl358.hostingexample.com'

No I'm a bit lost. Does anyone know how to retrieve actual domain with node?

0 Answers0