By default, Unleash runs on port 4242. The unleash start function allows you to customize port numbers like so:
unleash
.start({
databaseUrl: process.env.DATABASE_URL,
port: {CUSTOM}
})
.then(unleash => {
console.log(
`Unleash started on port ${unleash.app.get('port')}`,
);
});
However, if you set port to 443 for HTTPS support, Azure app service will throw an error that the command does not have permission to run at that port:
EACCES: permission denied 0.0.0.0:443
The solution lies in Azure's process.env.PORT variable:
If you output the value of process.env.PORT you will see a dynamic value such as:
\\.\pipe\fc1ef0b7-c1ce-4186-f9d8-fd0b5b0f6d0a
Azure is setting a named pipe in the env that Unleash can use as its "port". Therefore, the proper unleash setup would be as follows:
unleash
.start({
databaseUrl: process.env.DATABASE_URL,
pipe: process.env.PORT
})
.then(unleash => {
console.log(
`Unleash started on port ${unleash.app.get('port')}`,
);
});
Notice the option of "pipe" rather than "port" as a parameter for "start". Do not specify the "port" option in this case. Unleash documentation provides more insight into how the pipe works with node here.
P.S. One can also benefit from a web.config rule that redirects all http connections to https.