[Elastic Beanstalk] Deploy Angular & Node to Elastic Beanstalk

Posted by Jarxi on 2020-10-18

Deploy Angular & Node to Elastic Beanstalk

The default port for EB is 8080. Node will be started at port 8080.
It’s important to point Angular to port 8080. In environment.prod.ts, adds

1
2
3
4
export const environment = {
production: true,
BASE_API_URL: 'http://{YOUR_PUBLIC_IP_WITHOUT_PORT}'
};

then in terminalng build --prod. The enviroment.ts will be replaced by environment.prod.ts.

It’s also important to start Node at port 8080. The process.env.PORT is not set by a new Elastic Beanstalk instance. Thus at the end of index.js or server.js of Node, include

1
2
const port = process.env.PORT || 8080;
app.listen(port, () => console.log(`Server running on port ${port}`));


支付宝打赏 微信打赏

赞赏一下