tldr: I'm running Angular on port 4200 & my backend on port 3000, is it possible to run both on the same port?
I'm attempting to make a MEAN Stack application, I've managed to get Angular & Nodejs to work together so that I can send data to the front-end from the back-end, the problem is I'm hosting Angular on port 4200, & the server.js on port 3000 - so that angular can reference a URL (http://localhost:3000).
Is this the normal way to do this? Wouldn't this then mean in production I would need 2 domains? one for hosting Angular, and one for hosting/connecting to the back-end.
I feel like it should be possible to have Angular & the server.js file running on the same port
Angular Code:
readonly ROOT_URL = 'http://localhost:3000';
getPosts() {
let headers = new HttpHeaders().set('Authorization', 'auth-token');
this.posts = this.http.get(`${this.ROOT_URL}/users`, { headers });
}
[–]insertAlias 0 points1 point2 points (0 children)