I have hosted my loopback 4 application on iisnode windows web app, which is giving the port as pipe and in my loopback 4 application i am reading port as Process.env.PORT
. And i am getting the error:
Cannot start the application. RangeError [ERR_SOCKET_BAD_PORT]: Port should be >= 0 and < 65536. Received \.\pipe\fde1f2c4-428f-5513-8114-c9520f1ba02d
I tried by manually giving port 80, 443 but that is not working and throwing error like
EADDRNOTAVAIL
Expected port to be a number but iisnode giving it as pipe, which loopback 4 is rejecting.
// index.js root file
const application = require('./dist');
module.exports = application;
// Run the application
const config = {
rest: {
port: (process.env.PORT|| 3000),
host: process.env.WEBSITE_HOSTNAME || "localhost",
openApiSpec: {
setServersFromRequest: true,
},
},
};
application.main(config).catch(err => {
console.error('Cannot start the application.', err);
process.exit(1);
});
// index.ts inside src
import {myApplication} from './application';
import {ApplicationConfig} from '@loopback/core';
export {myApplication};
export async function main(options: ApplicationConfig = {}) {
const app = new myApplication(options);
await app.boot();
await app.start();
const url = app.restServer.url;
console.log(`Server is running at ${url}`);
return app;
}