Kubernetes Nginx upload large file 400 No 'Access-Control-Allow-Origin' Kubernetes Nginx upload large file 400 No 'Access-Control-Allow-Origin' kubernetes kubernetes

Kubernetes Nginx upload large file 400 No 'Access-Control-Allow-Origin'


The problem is that you are trying to upload the file from a different domain than the one specified in the ingress. It may be the same domain but a different port, protocol (http/https), prefixed with www., etc

By default, the browser doesn't allow those requests, because of security concerns. To allow them you should enable CORS: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Fortunately, it's quite easy to enable CORS in an ingress, just add the following annotations to your api's ingress resource:

nginx.ingress.kubernetes.io/enable-cors: "true"nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, OPTIONS"nginx.ingress.kubernetes.io/cors-allow-origin: "https://web.domain.xxx"

More info about those annotations here