1// in NodeJS (3000 port) make:
2app.get('/api/user', (req, res) => {
3 res.json({});
4});
5
6// in Angular (4200 port):
7// make call
8async ngOnInit(): Promise<void> {
9 let result = await this.http.get("http://127.0.0.1:4200/api/user").toPromise();
10
11 console.log("Result: ", result);
12
13}
14
15// create a file (proxy.conf.json) in a root directory of Angular, which conteins:
16{
17 "/api": {
18 "target": "http://localhost:3000",
19 "secure": false
20 }
21}
22
23// start Angular
24ng serve --proxy-config proxy.conf.json
25