0

Usually (without kubernetes, on my local machine), when I access the app it sends a get request to an API endpoint and it populates my angular app with information from there.

However, after I have uploaded the angular and the backend app to kubernetes and I access my angular app, the homepage loads but I get a 404 CORS errors from the API endpoint calls and no information is fetched so I just have a unpopulated homepage.

I have tried to use the information provided in this link but to no avail - meaning to start a chrome browser without security.

I also have added in my nginx file the information below but still doesn't work. enter image description here

What information would you need to help you better understand the situation? I'm not sure what I should share.

Here is the angular app service yaml.

apiVersion: v1
kind: Service
metadata:
  name: powerplant-angular-service
spec:
  selector:
      app: powerplant-angular
  type: ClusterIP
  ports:
    - protocol: TCP
      port: 80

P.S. I have tested the kubernetes back-end API endpoint through postman and it works as expected, so the issue isn't from that application.

Art
  • 39
  • 1
  • 9

1 Answers1

0

Set the annotations in the config of Ingress as below.

 metadata:
   annotations:
     nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, OPTIONS"
     nginx.ingress.kubernetes.io/enable-cors: "true"

checkout the React w/ Kubernetes deployed API giving cors error

hope this works

KRyun
  • 23
  • 1
  • 6
  • it's not a production app so I don't have an ingress, I only have a service and then I either port forward the app pod or the app service. I have updated the question and added the service. – Art Jul 27 '22 at 08:56