CORS Not Working

Hi,

Have configured Allowed Headers in Cors plugin, but i’m not able to get Access-Control-Allow-Headers in response, due to which options pre-flight call is failing.

Is there any thing wrong on the cors plugin, or do i have to configure any other parameter.

FYI, have tried enabling cors plugin on route and as well as service, dint work.

@Irshad_G
Which kong version do you use? And do you use Kong Ingress Controller?
Please give more information about your configuration. It is better to get quick help.

@dieunb
Kong version : 2.0.3
Its community edition, installed on ubuntu with postgress

And could you show me the cors configuration? In my kong, cors plugin config is following below:

---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: demo-cors
  namespace: default
config:
  methods:
    - HEAD
    - GET
    - POST
    - PUT
    - PATCH
    - DELETE
  headers:
    - Authorization
    - Content-Type
  origins:
    - "*"
  credentials: true
plugin: cors

Please ensure that you have enable the plugin on a Kubernetes service or Ingress resource.
The following guide should help:

Would you share the error ?

@hbagdi we have the same issue with Kong Ingress Controller (Kong 2.2) in kubernetes. Anyone can help?

CORS Plugin (CORS plugin | Kong)

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: cors-app
  namespace: dev
config: 
  origins:
	- https://www.domain.com
  methods:
	- GET
	- POST
  headers:
	- Accept
	- Accept-Version
	- Content-Length
	- Content-MD5
	- Content-Type
	- Date
	- X-Auth-Token
  exposed_headers:
  	- X-Auth-Token
  credentials: true
  max_age: 3600
  preflight_continue: false
plugin: cors

Ingress route

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: dev-ingress
  namespace: dev
  annotations:
	kubernetes.io/tls-acme: "true"
	cert-manager.io/cluster-issuer: letsencrypt-prod
	kubernetes.io/ingress.class: kong
	konghq.com/strip-path: "true"
	konghq.com/protocols: https
	konghq.com/https-redirect-status-code: "301"
	konghq.com/plugins: cors-app
spec:
  tls:
	- secretName: dev-api-domain-com
	  hosts:
		- dev.domain.com
  rules:
	- host: dev.domain.com
	  http:
		paths:
		  - path: /user
			backend:
			  serviceName: dev-service
			  servicePort: 5000