React w/ Kubernetes deployed API giving cors error React w/ Kubernetes deployed API giving cors error kubernetes kubernetes

React w/ Kubernetes deployed API giving cors error


Why are the cors settings commented?

nginx.ingress.kubernetes.io/configuration-snippet: |  add_header Access-Control-Allow-Origin $http_origin;  add_header Access-Control-Allow-Methods "POST, GET, OPTIONS";  add_header Access-Control-Allow-Credentials true;

Same issue on GitHub


Okay, after alot of research and with the help of the other answers I did the following:

  1. I changed the request to the backend (from the client side) to https instead of http. This fixed the error Redirect is not allowed for a preflight request
  2. I changed the config ingress nginx config to get rid of the error multiple values in Access-Control-Allow-Origin :
apiVersion: extensions/v1beta1kind: Ingressmetadata:  name: ingress-service  annotations:    nginx.ingress.kubernetes.io/default-backend: ingress-nginx-controller    kubernetes.io/ingress.class: nginx    ## tells ingress to check for regex in the config file    nginx.ingress.kubernetes.io/use-regex: "true"    nginx.ingress.kubernetes.io/configuration-snippet: |      add_header Access-Control-Allow-Methods "POST, GET, OPTIONS";      add_header Access-Control-Allow-Credentials true;    nginx.ingress.kubernetes.io/enable-cors: "true"    nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, OPTIONS"

I hope it helps others as well.


Redirect is not allowed for a preflight request.

Seems like there is a redirect happening. There isn't enough information to conclude where. My guess is that you have TLS set up on your Ingress and http://cultor.dev/api/users/signin is being automatically redirected to https.