Can't setting CORS Traefik V2

I'm trying to raise the version of Traefik I'm building on Kubernetes from v1 to v2.

I was able to update itself, but when I try to use the application after updating the Traefik version to v2, I get a CORS error.

I checked the documentation and found that CORS can be configured in the middleware configuration, so I configured it as follows.

trying to access from

    accessControlAllowMethods= ["GET", "OPTIONS", "PUT", "POST", "DELETE"]
    accessControlAllowOriginList = ["https://*"]
    accessControlMaxAge = 100
    addVaryHeader = true
  • ingress setting
kind: Ingress
  name: example-app
  labels: example-app
  annotations: "true" https "true" traefik
    - host:
          - path: /
            pathType: ImplementationSpecific
              serviceName: example-app
              servicePort: 443

but this problem not sloved.

When I checked the error, I found that the preflight had failed.

has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I would like to know if there is any part of the problem and if there are any other settings that need to be made.

Thank you.

Loading the configured middleware solves the preflight problem, but the CORS problem is still there.

Hi there @yuzujoe, I think the plugin traefik-plugin-cors might be able to help you :slight_smile:
See the pilot's plugin page.

1 Like