I am running a kubernetes cluster on an openstack cloud and have a pod each for my angular frontend and my phoenix/elixir backend. When the user first calls the frontend through an ingress exposed node server, http calls to the backend are performed at the service level inside the kubernetes cluster and sent to the user. However, once the user navigates in the angular 8 environment, the http calls go directly to the same url the kubernetes services used to communicate, thus failing to resolve the address. So is it absolutely necessary to expose the backend api endpoint to the internet in order for the user to be able to get around the site ? Or is there a way to pipe everything through the frontend ingress access point ?
On request:
The ingress.yaml is:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: ingress
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host:
http:
paths:
- path: /api
backend:
serviceName: webapp
servicePort: 8000
- path: /
backend:
serviceName: frontend
servicePort: 8200
Regarding the http calls, the auth service does this to login:
login({ email, password }): Observable<User> {
const params = {
data: { attributes: { email: email, password: password } }
};
return this.http.post<{ data: User }>('login', params).pipe(
map(({ data: user }) => {
this.setTokenInLocalStorage(user, 'user');
this.store.dispatch(
this.actions.getCurrentUserSuccess(
JSON.parse(localStorage.getItem('user'))
)
);
this.store.dispatch(this.actions.loginSuccess());
return user;
}),
tap(
_ => this.router.navigate(['/']),
error => this.toastrService.error(error.error.errors.detail, 'ERROR!')
),
catchError(error => {
return of(error);
}) as any
);
}