X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fui%2Fweb%2Fstart.js;h=ed6e3e01ff65c0f81696ba9805a5b622f8c5169c;hb=d5ece62197ba88b0af166e2bfefc03b03a6c7076;hp=e804fc11484b6cf2c7a36f604bd070fa69b7f6c5;hpb=32de5a575189d226213641f5ee36004f8454cb50;p=e-mobility-charging-stations-simulator.git diff --git a/src/ui/web/start.js b/src/ui/web/start.js index e804fc11..ed6e3e01 100644 --- a/src/ui/web/start.js +++ b/src/ui/web/start.js @@ -3,8 +3,9 @@ const path = require('path'), http = require('http'), serveStatic = require('serve-static'); -const PORT = process.env.PORT || 3030, - uiPath = path.join(__dirname, './dist/'); +const isCFEnvironment = process.env.VCAP_APPLICATION !== undefined, + PORT = isCFEnvironment ? parseInt(process.env.PORT) : 3030, + uiPath = path.join(__dirname, './dist'); const serve = serveStatic(uiPath); @@ -12,4 +13,4 @@ const server = http.createServer(function onRequest(req, res) { serve(req, res, finalhandler(req, res)); }); -server.listen(PORT, () => console.info(`http://localhost:${PORT}`)); +server.listen(PORT, () => console.info(`App running at: http://localhost:${PORT}`));