Skip to content
This repository was archived by the owner on Jun 2, 2020. It is now read-only.
This repository was archived by the owner on Jun 2, 2020. It is now read-only.

Hosting Web Apps on IPFS #405

@cwaring

Description

@cwaring

Special Edition: IPFS Docs v2 featuring VuePress

Vuepress on IPFS

Thanks to @hugomrdias and @lidel for chatting through all various scenarios yesterday, below are a few thoughts and next steps balanced against time/effort and overall impact.

The first (and perhaps most important) thing to note is that this problem is not isolated to VuePress, and is currently causing many common web applications with client-side routing and absolute paths to appear broken when loaded via a gateway URL, such as http://gateway.ipfs.io/ipfs/<cidv0>.

In order to make IPFS a first-class citizen for hosting web apps, the consensus is that we should move to subdomain model as soon as possible (e.g. https://<cidv1b32>.ipfs.dweb.link).

  • This provides origin isolation for app security and session storage, while also fixing client-side routing and asset issues that people are facing with some of the most popular webpack application bundlers that currently rely on absolute paths (a few examples are Next, Gatsby, create-react-app, Nuxt, and VuePress).

  • Additionally, this change will provide familiarity to new users attempting to host these type of web apps on IPFS — thus lowering the barrier to adoption and increasing our reach.

The subdomain pattern is a familiar one for developers. Most hosting services use a https://<subdomain>.<service>.<ext> pattern, and with the recent efforts/refactors across our projects we are very close to making this a reality for IPFS too. To that end, we believe we should invest our effort towards that direction instead of patching frameworks on a case-by-case basis.

With that said, here is a summary of our current options:

Option 1: Make IPFS Companion "redirect to gateway" opt-in and default to dweb links


[certainty: high, effort: medium, impact: high]

This option ensures that IPFS Companion will not automatically push users to load a resource via their local gateway node by default, leaving people with a broken experience when an app fails to load correctly. @lidel also suggests that we should move to an opt-in model, so that users have the option to explore sites via their local gateway instead of forcing this as default behaviour. Ultimately, an in-browser proxy would allow us to use cidv1 urls locally alongside dweb links; however, this won't be the case until further work has landed in the Chrome/Firefox vendor space.

For this to work successfully, the following tasks must be completed:

This does mean that a VuePress site will not run locally until we have a subdomain gateway in go-ipfs that we can use as a proxy in ipfs-desktop. However, we believe this is an acceptable tradeoff in the meantime, as this is a niche use case — particularly considering that the main app will provide PWA functionality with offline caching via service workers (enhancing the experience on all platforms, including mobile).

Related issues/efforts:

Option 2: Create a plugin to rewrite VuePress compiled output


[certainty: medium, effort: medium, impact: low]

As sketched out in this gist, we could build a post-process plugin that rewrites all the absolute paths to relative ones, making an app work regardless of path depth. However, this could have a number of unknown and potentially experience-breaking side effects such as interfering with interactivity, routing, failure of offline caching via PWA, and uncertainty around how plugins may respond.

This is approach would be similar to gatsby-plugin-ipfs and may be acceptable for simple sites — but post-processing compiled assets with regex is a fragile and messy solution. We believe this should only be done as an absolute last resort or a stopgap option.

Option 3: Fix the problem upstream in VuePress


[certainty: low, effort: high, impact: medium]

We could apply development effort to fix this issue upstream in VuePress. Such work would help resolve additional absolute-path-related issues for other users; however, it's strongly unlikely that we could solve the key issues, patch affected plugin dependencies, and land a merged PR in a timely fashion without unnecessarily delaying the launch of IPFS docs and losing valuable beta user testing time.

The effort here is complex, involves consensus with multiple third parties, and only adds value to a niche use-case. If absolutely necessary, we could investigate pursuing this in the new year, but our recommendation is to avoid postponing beta launch by pursuing one of the other options in the meantime.

Related issues:

Option 4: Use GitHub Pages, Netlify or similar (stopgap)


[certainty: max, effort: zero, impact: 🤷‍♂️]

We are setup this way at the moment and it has enabled us to focus on delivering end user functionality in the docs beta until there was a solution in place to fully migrate to cidv1b32.

Note that Filecoin and IPLD docs are currently configured like this too.

Summary

We are keen to pursue option 1 for maximum overall impact, however I'd like to hear your thoughts. 👂✨

ref: #271

Metadata

Metadata

Assignees

Labels

dif/hardHaving worked on the specific codebase is importanteffort/weeksEstimated to take multiple weekstopic/design-front-endFront-end implementation of UX/UI work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions