From 6f3baa67902dfe3fffd20609845a4aadc14c3e88 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 5 Aug 2015 13:07:35 -0700 Subject: [PATCH] start a quick intro guide to making ipfs webapps --- webapps/webapps.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 webapps/webapps.md diff --git a/webapps/webapps.md b/webapps/webapps.md new file mode 100644 index 0000000..8f9440e --- /dev/null +++ b/webapps/webapps.md @@ -0,0 +1,40 @@ +# WebApps on IPFS + +This is a short guide on how to start making your own web applications on top of +ipfs. + +Ipfs provides an http api to interact with the daemon through, but by +default it has a few security features enabled that make it difficult for people +to use the api in their own apps. There are two different routes you could take +to use the API, first, is to run your own webserver, and make http requests to +localhost:5001. This is in my opinion the easier route for development. For this +to work, you'll need to disable cross origin check by running the daemon with +the environment variable `API_ORIGIN` set to `*`: + +``` +$ export API_ORIGIN="*" +$ ipfs daemon +``` + +Now all of the requests you make to the api will work just fine. + +The second route is to publish your app to ipfs (via `ipfs add -r`) and load +it through the http server at `localhost:5001/ipfs/`. This +does not require you to change the `API_ORIGIN` variable (as you'll be loading +the app from the correct origin) but you will need to tell the daemon that +you want it to allow you to load different apps through the server on the API port. +By default you can only load the ipfs webui through the API port, this is a +security measure to prevent random web pages from making api calls on your daemon. +To disable this for testing your app, run the daemon like: + +``` +$ ipfs daemon --unrestricted-api +``` + +So now that youre able to load your app, you probably want to start making +those api calls I mentioned (you *are* writing an ipfs app, after all). We +recommend everyone use the +[browserified node-ipfs-api](https://github.com/ipfs/node-ipfs-api). + +By +[whyrusleeping](https://github.com/whyrusleeping)