Custom Response Headers are not set when using file provider

Hey @ldez

I'm trying to set custom response headers using the file provider, but the headers are not being applied to the responses.

Dynamic file configuration

[http.routers.api]
  rule = "Host(`traefik.sensehawk.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
  service = "api@internal"
  middlewares = ["auth"]

[http.middlewares.auth.basicAuth]
  users = [
    "XXXXX:XXXXXXXXXXXXXXXXXX" 
  ]

[http.middlewares]
[http.middlewares.usersData.forwardAuth]
  address = "http://127.0.0.1:3000/"
  authResponseHeaders = ["x-user-data", "authorization"]
  trustForwardHeader=true

[http.middlewares.cors.headers]
  accessControlAllowMethods = ["OPTIONS", "GET", "POST", "PUT", "PATCH", "DELETE"]
  accessControlAllowHeaders = ["Authorization", "Content-Type", "X-Vault-Password", "User-Uid", "User-Email", "User-Organization", "User-Labels", "User-Role", "User-Internal", "User-Is_Owner", "User-Is_Manager", "Range", "Content-Range"]
  accessControlExposeHeaders = ["X-Total-Count", "X-Result-Count", "X-Page-Count"]
  accessControlAllowOriginList = ["*"]
  addVaryHeader = true

[http.middlewares.testHeader.headers]
    [http.middlewares.testHeader.headers.customResponseHeaders]
        X-Custom = "some-value"

Also, in the dashboard, I see the middleware as below.

Please help!

Hello,

you have to set the middlewares on your routers:

[http.routers.api]
  rule = "Host(`traefik.sensehawk.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
  service = "api@internal"
  middlewares = ["auth", "headers", "testHeader"]
1 Like

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