Support for SPA "mode" in HTTP gateway

Now that the http gateway has support for 404s as of 0.6, we started thinking about other HTTP type options tuned for hosting apps, rather than just data.

If you’re interested in this, please leave a comment here, or continue the discussion in the Fission forum, which this is a cross-post of.

In hosting applications on IPFS, there is an issue with Single Page Applications (SPAs). They have to use hash based routing when they are deployed to IPFS.

To better support SPAs and “clean” URLs, the server needs to know to redirect all paths for a route to a root index.js or similar, aside from some static path.

We could add this by running a proxy in front of our IPFS gateway, and make this work with a flag just for apps hosted on Fission, but that defeats the purpose of making things work anywhere someone has IPFS running. Including developers running a go-ipfs node locally.

We could contribute a patch for this and work on getting it submitting into go-ipfs upstream, if there is interest. We did this for ipfs ignore already.

Much like the new 404 support in go-ipfs 0.6, there would need to be a file in the file tree that signals to turn on SPA-mode for a set of directories.

Perhaps rather than re-inventing things, since this is for HTTP, we can lean on existing patterns, like the .well-known folder at the root of a website domain.

A variety of different frameworks for SPA mode use slightly different commands for defining routes, as well as different server / hosting providers.

Next Steps

Cross Post to IPFS forum and look for interested people to test, participate in spec, etc (DONE – this is the post!)

We would make an initial spec, reach out to different frameworks (Elm, React, Vue, Svelte, NextJS etc etc), and look for common practices in hosting providers (eg CNCF buildpacks for static sites, nginx config, vercel, netlify, etc etc).

Pool funds and identify go-lang developer who could create initial implementation and make PR to upstream

Work to get changes into upstream. Fission, others can run patched gateway (likely patch against 0.7 to make it easy for others to run)


I think this would be fantastic, can I donate some crypto towards pushing this forward?

1 Like

Sure, I can look at setting up a pool for this.

What would be your top three cryptocurrencies to use?

To receive a donation in? EOS, ETH, BTC in order of preference.

1 Like

For those that might still be following along, it looks like supporting _redirects could be a thing to be added to go-ipfs, follow the issue here Proposal: native redirects config · Issue #7392 · ipfs/go-ipfs · GitHub

1 Like

We have a PR by @justincjohnson and this is ready for others to try out on their own.

More info on the Fission forum:

1 Like