Traefik not setting Access-Control-Allow-Origin header

Hey,

I am trying to have traefik set the Access-Control-Allow-Origin header to http://localhost:8080. I'm using the following docker labels:

- "traefik.http.middlewares.cors.headers.accessControlAllowOriginList=http://localhost:8080"
- "traefik.http.routers.myrouter.middlewares=cors"

But I still get a CORS error because the header is not present. However, if I set the value of accessControlAllowOriginList to * the header is present.

Am I missing something obvious as to why traefik is not setting the header when trying to set it to a value other than *?

1 Like

Hey @Steffeeen,

I have had the same issue (traefik v2.9). Although I haven't found the solution for the accessControlAllowOriginList option, I ended up setting the Access-Control-Allow-Origin header explicitly using the customResponseHeaders configuration option.

In your case, it would be:

- "traefik.http.middlewares.cors.headers.customResponseHeaders.Access-Control-Allow-Origin=http://localhost:8080"
- "traefik.http.routers.myrouter.middlewares=cors"

Hope it helps.

1 Like