Please find my below use case:
There is a backend web service developed in Java running at http://localhost:8080 and an angular UI application running at http://localhost:4200. Now my requirement is on successful login, Backend service sets cookies in the response object.
After that, all subsequent requests from UI to the backend service should be content set cookies by the backend service.
Issue:
As the backend is running on a different port, UI is not able to read the cookies and all subsequent requests from UI to the backend is not containing cookies.
Could anyone please help me with this issue?
For production you should use nginx or Apache in order to work on the same port.
For development you can define a path for backend, for example /api/ and tell Angular redirect all requests to this path to your backend server(on another port) this look like
Official guide https://angular.io/guide/build#proxying-to-a-backend-server
Another one https://juristr.com/blog/2016/11/configure-proxy-api-angular-cli/