Proxy redirects adding a canonical link header

I have two Netlify sites:

  1. elated-hugle-8a8255
  2. pensive-lalande-16cf57

1 is deployed on the custom domain rishav.io

I have a proxy redirect set up on 1.

[[redirects]]
    from = "/librepad/*"
    to = "https://pensive-lalande-16cf57.netlify.app/:splat"
    status = 200
    headers = {Link = '<https://rishav.io/librepad/>; rel="canonical"'}

The idea is to serve the 2nd Netflify site on a subpath of the first. This setup works fine. However, I see that Netfify adds a Link header on the 2nd site. I don’t understand why? Trying to manually set the Link header also does not work.

❯ curl --HEAD https://rishav.io/librepad/
HTTP/2 200
cache-control: public, max-age=0, must-revalidate
content-length: 0
content-type: text/html; charset=UTF-8
date: Tue, 08 Sep 2020 01:16:23 GMT
etag: "a07be2c799d0a83f6a44ab72d4cb4542-ssl"
link: <https://rishav.io/>; rel="canonical"
strict-transport-security: max-age=31536000
age: 0
server: Netlify
x-nf-request-id: 58a786cc-c001-45fa-919e-e27399b819cc-30188799

Bump, would be really helpful if someone looked into this.

I think you may be a bit confused about what the header rule there does.

When you proxy redirect from a site to another, we SEND that header to the “another” site - so you are in essnence setting an HTTP REQUEST (not response) header, to the site elated-hugle-8a8255 in the request. This won’t have any effect on the output from that remote site, in most cases.

Could you set the custom header on the pensive-lalande site, using our custom headers feature? That should work better:

…since our system will put that response on the proxy response, which should get passed on from the main site.

Thank you! That worked for me.

Could I know the reason why the Link header is set in the first place? That behavior is not documented anywhere as far as I can tell. I genuinely see what scenario it would be useful in.

Hey @xrisk, one such example I believe would be this:

We set it in some cases, for SEO purposes, as described here: