You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+18-19Lines changed: 18 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -25,31 +25,29 @@ var ipfs = ipfsAPI('localhost', '5001') // leaving out the arguments will defaul
25
25
26
26
### In the Browser through browserify
27
27
28
-
Same as in Node.js, you just have to browserify the code before serving it.
28
+
Same as in Node.js, you just have to [browserify](https://github.com/substack/node-browserify) the code before serving it. See the browserify repo for how to do that.
29
29
30
30
### In the Browser through `<script>` tag
31
31
32
-
Make the [ipfsapi.min.js](/ipfsapi.min.js) available through your server and load it using a normal `<script>` tag, this will exporrt the `ipfsAPI` constructor on the `window` object, such that:
32
+
Make the [ipfsapi.min.js](/ipfsapi.min.js) available through your server and load it using a normal `<script>` tag, this will export the `ipfsAPI` constructor on the `window` object, such that:
33
33
34
34
```
35
35
var ipfs = window.ipfsAPI('localhost', '5001')
36
36
```
37
37
38
-
If you omit the host and port, the api will parse window.host, and use this information. I.e, this also works:
38
+
If you omit the host and port, the api will parse `window.host`, and use this information. This also works, and can be useful if you want to write apps that can be run from multiple different gateways:
39
39
40
40
```
41
41
var ipfs = window.ipfsAPI()
42
42
```
43
43
44
-
This can be useful if you want to write apps that can be run from multiple different gateways.
45
-
46
44
#### Gotchas
47
45
48
-
When using the api from script tag for things that require buffers (ipfs.add, for example), you will have to use either the exposed ipfs.Buffer, that works just like a node buffer, or use this [browser buffer](https://github.com/feross/buffer)
46
+
When using the api from script tag for things that require buffers (`ipfs.add`, for example), you will have to use either the exposed `ipfs.Buffer`, that works just like a node buffer, or use this [browser buffer](https://github.com/feross/buffer).
49
47
50
48
## CORS
51
49
52
-
If are using this module in a browser with something like browserify, then you will get an error saying that the origin is not allowed. This would be a CORS ("Cross Origin Resource Sharing") failure. The ipfs server rejects requests from unknown domains by default. You can whitelist the domain that you are calling from by exporting API_ORIGIN and restarting the daemon, like:
50
+
If are using this module in a browser with something like browserify, then you will get an error saying that the origin is not allowed. This would be a CORS ("Cross Origin Resource Sharing") failure. The ipfs server rejects requests from unknown domains by default. You can whitelist the domain that you are calling from by exporting `API_ORIGIN` and restarting the daemon, like:
0 commit comments