Hi,
I am trying to update an existing header using a middleware with customResponseHeader.
This is my config using File provider and a yaml file:
http:
middlewares:
updateCookieHeaders:
headers:
customResponseHeaders:
X-Custom-Header: "{{ `Hello World` }} {{ printf `%#v` . }}"
Set-Cookie: "{{ if $cookie := .Response.Header.Get `Set-Cookie` }} {{ $cookie}}; SameSite=Strict {{ end }}"
Spoiler: it does NOT work
Yes the middleware is applied and called. Removing the Set-Cookie header modification does set my X-Custom-Header.
Printing the Go template context in my X-Custom-Header reveals that it's false. But I thought it should be the Response object.
What am I missing here?
Is it even possible to do such modifications?
That's Traefik's log output:
time="2023-02-17T10:47:31+01:00" level=error msg="Error occurred during watcher callback: /etc/traefik/conf/common.yml: template: :33:49: executing \"\" at <.Response.Header.Get>: can't evaluate field Response in type bool" providerName=file