0

I am running in kubernetes and I have a default backend service configured, and my apis have their own Ingress objects which seem to be working and have CORS setup correctly.

But if you happen to call a route that isn't covered by one of the paths in the ingress it gives me a CORS error, which I'm assuming is falling back to the default backend.

So the question is, how can I configure the CORS headers for the default backend service when using the nginx-ingress in kubernetes?

justin.m.chase
  • 13,061
  • 8
  • 52
  • 100
  • Others here are likely to ask what you have tried so far and why it didn’t work, etc. – sideshowbarker Jan 13 '23 at 11:49
  • Also, what other Q&As among https://stackoverflow.com/questions/tagged/nginx-ingress+cors did you look at so far, and did you find that none of those provided any clues as to what direction to take – sideshowbarker Jan 13 '23 at 11:50
  • I haven't tried anything yet, my main pods have CORS setup correctly but I just have no idea how to configure it for the default backend. – justin.m.chase Jan 13 '23 at 20:28
  • To enable Cross-Origin Resource Sharing (CORS) in an Ingress rule, **add the annotation nginx.ingress.kubernetes.io/enable-cors: "true"**. This will add a section in the server location enabling this functionality. go through [link](To enable Cross-Origin Resource Sharing (CORS) in an Ingress rule, add the annotation nginx.ingress.kubernetes.io/enable-cors: "true". This will add a section in the server location enabling this functionality). – Veera Nagireddy Jan 19 '23 at 12:11
  • Yes and I've done that but we're talking for the default backend, meaning when a request doesn't match any ingress it falls back to the default backend and then has a cors issue. – justin.m.chase Jan 20 '23 at 13:34

0 Answers0