F
F
freestm2017-09-13 20:35:52
JavaScript
freestm, 2017-09-13 20:35:52

If the client is running angular and the server is running nodejs, where does the user send requests?

Angular on port 3000, nodejs on port 4200. Should the server accept requests and redirect to the appropriate angular routing or does angular accept requests and access the server for data? Something I'm confused...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Skibin, 2017-09-13
@megafax

Angular on port 3000

This is in fact your static
And this is the dynamics
In this interpretation, all downloads of modules and other things should go to :3000 and all API requests to :4200.
It’s better to do everything on one port, just add all the angular in /js/ and in nodejs give everything that came to this route as it is, like pictures

D
Dimonchik, 2017-09-13
@dimonchik2013

Chrome + F12
nothing prevents both / both

M
MOTORIST, 2017-09-16
@MOTORIST

The client requests data, the server responds. Angular client, node server.
On the client

this.http.get('http://localhost:4200/api/items').subscribe(data => {
      this.results = data['results'];
});

If you want the client to listen to the server, fasten the websocket.
In production, add nginx.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question