The host of a URL can be denoted by having the prefix, //
:
> var mainServerURL = '//localhost:8080/';
undefined
> var tempFilesDir = '/temp';
undefined
> url.resolve(mainServerURL, tempFilesDir)
'//localhost:8080/temp'
Without it, localhost:
is being treated as the protocol rather than the hostname:
> url.parse('localhost:8080/', false, true)
{ protocol: 'localhost:',
host: '8080',
port: null,
hostname: '8080',
... }