I was able to enable cors for http url but not for https. Getting below error when requesting over https.
Access to XMLHttpRequest at 'https://foo.company.com/socket.io/?EIO=4&transport=polling&t=OPJurnL' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Below is my ingress.yaml file for http request.
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: cors
namespace: foo-ns
spec:
headers:
accessControlAllowMethods:
- "GET"
- "OPTIONS"
- "PUT"
- "POST"
accessControlAllowOriginList:
- "*"
customResponseHeaders:
X-Foo-Name: "foo"
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: foo-ingress
namespace: foo-ns
spec:
entryPoints:
- web
routes:
- kind: Rule
match: Host(`foo.company.com`)
priority: 1
middlewares:
- name: cors
namespace: foo-ns
services:
- kind: Service
name: foo
namespace: foo-ns
port: foo-port
Below is my ingress.yaml file for https request.
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: cors
namespace: foo-ns
spec:
headers:
accessControlAllowMethods:
- "GET"
- "OPTIONS"
- "PUT"
- "POST"
accessControlAllowOriginList:
- "*"
customResponseHeaders:
X-Foo-Name: "foo"
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: foo-ingress
namespace: foo-ns
spec:
entryPoints:
- websecure
routes:
- kind: Rule
match: Host(`foo.company.com`)
priority: 1
middlewares:
- name: cors
namespace: foo-ns
services:
- kind: Service
name: foo
namespace: foo-ns
port: foo-port
tls:
domains:
- main: company.com
sans:
- "*.company.com"
secretName: my-cert
Not sure why the same middleware for cors configurations isn't working for https protocol. Kindly help.