I wrote a middleware function to customize the headers to a proxied response. The server I am proxying to returns headers that I want to remove.
No matter how I do it, the response headers from the proxied service are always present on the request. I tried overwriting the header, and tried removing it
const headers = new Headers(); headers.set("x-robots-tag", "foo"); headers.set("foo", "bar"); return NextResponse.rewrite(new URL(path, pantheonURL), { headers, });
In this example, I will see the "foo" header correctly, but the "x-robots-tag" header is overwritten by the proxy server. Is there anything I can do?