-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect Opt-out via URL Hints #505
Conversation
- cleanup of existing opt-out rules - detect `x-ipfs-no-redirect` in the URL and skip redirects
preload requests require explicit opt-out hint as noted in #505
Shouldn't this be done as a |
@victorbjelkholm that was my first thought, but the idea got hit by API limitations quite fast:
Unfortunately, |
unless I'm missing something, I feel like if a dev wants to force a specific gateway then the urls should include that gateway. Is there a issue with |
@olizilla right now we detect IPFS paths on any website and redirect them. This means browser extension opportunistically upgrade transport to local IPFS node everywhere IPFS paths are used. The problem this PR solves is that there is no opt-out mechanism for rare cases such as public gateway preloads and bug workarounds. @victorbjelkholm Even if opt-out via a header was doable, it would come at a price: This means opt-out via HTTP Header would require additional setup step from gateway administrators, namely to include |
Should we avoid re-writing IPFS urls that explicitly refer to a custom gateway?
|
Ok, time for some context: The gateway at What this PR changes is to add optional "opt-out" mechanism: extension looks at URL of requests made to any public gateway and if it sees ps. Historical discussion about opportunistic HTTP2IPFS upgrade on every website can be found in #16. |
These parts had a lot of scar tissue, this commit cleans things up and makes codepaths responsible for request mutation easier to grasp.
I think I was just not clear enough in my initial description what this PR does, sorry about that. The change is really, really small: TL;DR: this PR adds support for
function isSafeToRedirect (request, runtime) {
// Do not redirect if URL includes opt-out hint
if (request.url.includes('x-ipfs-companion-no-redirect')) {
return false
} That is all. The rest is just some cleanup/refactoring without any functional changes. |
This is just backporting of PR #509
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the cleanup, actual change introduced by this PR is 4 lines long.
Let's release it to Beta.
I don't feel totally comfortable about supporting this. If it's just for companion, perhaps the token to check for should be |
TL;DR: this PR adds support for
x-ipfs-no-redirect
x-ipfs-companion-no-redirect
(#510 ) symbol as a way to disable gateway redirect for a single request, without disabling anything globally.That is all. The rest is just some cleanup/refactoring without any functional changes.
Background
This PR adds an URL-based opt-out from global gateway redirect that website developers can rely on to ensure request goes to the specific HTTP gateway.
Potential consumers of this feature:
Details
webRequest.onBeforeRequest
.x-ipfs-no-redirect
x-ipfs-companion-no-redirect
) is present in URL.Thoughts?
cc @lgierth @victorbjelkholm @kyledrake