[SOLVED] Getting error 500 with CORS middleware while using OPTIONS method

Hi Traefik Community,

For some reason my traefik edge-router with the following CORS middleware is not able to handle OPTIONS method request, if I disable the CORS middleware the request is processed without any problem, after troubleshooting the issue the request is not reaching the backend service it's just getting stuck at the ingress controller and the traefik pods logs doesn't show too much information: - - [05/May/2021:22:04:17 +0000] "OPTIONS /life-journey/faceamountlimit/36/1000 HTTP/2.0" 500 21 "-" "-" 315265 "life-dev-life-journey-ingress-route-tls-b65bf12e144610f0c39a@kubernetescrd" "-" 2489ms

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
  name: dev-health-cors
  namespace: health  
      - "PUT"    
      - "GET"
      - "POST"      
      - "OPTIONS"
      - "DELETE"
      - "HEAD"      
      - "TRACE"
      - "PATCH"
      - "*"       
      - "*"
    accessControlMaxAge: 300
    addVaryHeader: true
curl --location --request OPTIONS 'https://example.com/life-journey/faceamountlimit/36/1000' --header 'Access-Control-Request-Method: GET' --header 'Access-Control-Request-Headers: authorization' --header 'Referer: https://example.azurewebsites.net/' --header 'Host: example.com' --header 'Origin: https://example.azurewebsites.net'

Any guidance that you can provide me it would really appreciated

I was able to solve the problem by changing the CORS middleware order as it was suggested by @tboerger in CORS headers are broken for me since 2.0.6

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.