Hmm… I thought about that when I wrote that reply. Maybe limiting the modification of content to just IPNS would be preferable. I mean, it would still be a non-faithful reply, but at least IPNS doesn’t carry any the “content matches CID” guarantee you mentioned and is expected to change over time. It would still not be a faithful relaying of content of course, but at least it doesn’t break stuff in any obvious way.
Here’s another thing I just considered: A much cleaner way to do it could involve redirecting requests from web browser to some frame/iframe page that embeds the original content with some request parameter (such as
?embedded-notice-frame=true). Server then sees this parameter, skips the redirect to the frame page and passes it on to the IPFS gateway as usual. The actual page content will not be modified. A very nice side-effect of this, is that the HTML and styles of the parent document does not risk being accidentally or purposely being modified by the embedded page (which should be treated as untrusted content in this case).
There may be some nice way to avoid the parameter to not confuse client-side scripts looking at their page’s query string, but none of the possible headers I found for this (
Origin) looked particularly promising. [Cookies and
Referer are often blocked amongst certain user groups,
Origin does not appear to be send on same-origin requests and
Something that could work however is calling
Sorry for the long reply, but when typing I just had the IFrame idea and had to research it / thing it through.