MHY
MHY

Reputation: 103

Issues with Kubernetes Ingress Configuration for Angular SSR and Static Services

I'm getting an issue with my Angular application when deploying with Kubernetes. The app works perfectly when I port-forward either the SSR or the static service to localhost. However, accessing the app through the DNS (demo.example.com) leads to a TypeError: Cannot read properties of undefined (reading 'call') in the console, which doesn't occur on the local setup.

Here's my Ingress configuration:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: c-frontend-dev
  namespace: development
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  ingressClassName: nginx
  rules:
    - host: "demo.example.com"
      http:
        paths:
          # Specific path for SSR
          - pathType: Prefix
            path: "/pages/subscriptions"
            backend:
              service:
                name: c-ssr-dev
                port:
                  number: 4000
          # Default path for static content
          - pathType: Prefix
            path: "/"
            backend:
              service:
                name: c-static-dev
                port:
                  number: 8080

I suspect there might be an issue with the Ingress setup, perhaps with the rewrite target or the way paths are being routed. Could someone with experience in configuring Ingress for an Angular app with both SSR and static hosting weigh in on whether there's something missing or misconfigured in this setup?

FYI: Here's the c-static-dev image creation looks like:

FROM node:18-alpine3.19 as build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build --prod-nocdn

# Serve using a lightweight static server
FROM node:18-alpine3.19
WORKDIR /app
COPY --from=build /app/dist/c/browser .
RUN npm install -g serve
CMD ["serve", "-s", ".", "-l", "8080"]
EXPOSE 8080

Any insights or suggestions would be greatly appreciated!

Upvotes: 0

Views: 80

Answers (1)

MHY
MHY

Reputation: 103

Turns out the issue is the caching config from cloudflare as i'm using it on my case.

Upvotes: 0

Related Questions