Skip to content
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

Differentiate between webui.ipfs.io and webui from kubo #2078

Closed
Tracked by #2074
SgtPooki opened this issue Jan 3, 2023 · 4 comments · Fixed by #2081
Closed
Tracked by #2074

Differentiate between webui.ipfs.io and webui from kubo #2078

SgtPooki opened this issue Jan 3, 2023 · 4 comments · Fixed by #2081
Assignees
Labels
effort/hours Estimated to take one or several hours P0 Critical: Tackled by core team ASAP status/in-progress In progress

Comments

@SgtPooki
Copy link
Member

SgtPooki commented Jan 3, 2023

I think we can have an environment variable on the webui deployment with countly APP ID and then an APP ID that would be used if that env var is not set. webui.ipfs.io deployments would be able to override the hardcoded APP ID, and kubo usage would use the hardcoded one. This will allow us to proceed without being blocked on any Kubo changes for making this happen

@SgtPooki SgtPooki mentioned this issue Jan 3, 2023
3 tasks
@SgtPooki SgtPooki assigned SgtPooki and unassigned 0xDanomite Jan 16, 2023
@SgtPooki SgtPooki added status/in-progress In progress P0 Critical: Tackled by core team ASAP effort/hours Estimated to take one or several hours labels Jan 16, 2023
@SgtPooki
Copy link
Member Author

i'm realizing now that since we're deploying webui assets as a CID and updating DNSlink, that we can't simply set the env var as we would with a typical deployment. If we were to migrate to fleek for deployment, this could be resolved in the manner described in the issue description, but without that, we may need to do some client side logic to determine which env we're running on

@lidel
Copy link
Member

lidel commented Jan 16, 2023

You can inspect window.location.origin and if it includes webui.ipfs or webui-ipfs then you know it was loaded via DNSLink (either public HTTP server or local node).

In similar fashion, you can detect when it was loaded via specific CID (origin or pathname will include CID).

Based on that, you can assign different APP ID and initialize telemetry with it.

@SgtPooki
Copy link
Member Author

SgtPooki commented Jan 16, 2023

it also looks like doing var foo = await fetch('/webui', {method: 'HEAD'}) gives us pretty unique results:

  1. Local run (or desktop run): response.redirected === false - it just works, and has 200 success... we should probably adjust dev server for this, but I think the below two items are the important ones.
  2. kubo run: reponse.redirected === true - kubo redirects /webui to the CID listed. I believe this redirect is unique to kubo
  3. webui.ipfs.io run: throws 404 - makes sense

Would this be a valid approach?

@lidel
Copy link
Member

lidel commented Jan 16, 2023

Yes, that will work too.

Might silently break if we ever change the way Kubo behaves, or we add /webui subdirectory to webui itself for some reason, but you can always do the window.location.origin.includes("webui-ipfs") || window.location.origin.includes("webui.ipfs") first to guard against that

Note - and . and lack of TLD because it can be loaded from various origins:

  • http://webui.ipfs.io.ipns.localhost:8080/ and Brave's http://webui.ipfs.io.ipns.localhost:48080/
  • https://webui-ipfs-io.ipns.dweb.link/
  • https://webui.ipfs.tech and matching gateway variants (if we ever move it away from .io)

@tinytb tinytb changed the title Ensure we have a way to differentiate between webui.ipfs.io and webui from kubo Differentiate between webui.ipfs.io and webui from kubo Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/hours Estimated to take one or several hours P0 Critical: Tackled by core team ASAP status/in-progress In progress
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants