Configuring universal-fs
How to use the universal-fs relay server API

How to use the universal-fs relay server API

Obtaining the url and token

In the browser

Get two cookies one named universal-fs-url, and the other universal-fs-token.

In Node

Read two files .fs/url.txt and .fs/token.txt

Tip: to get the url and the token you can use the internal helpers getToken() (opens in a new tab) and getUrl() (opens in a new tab)

Making requests

Send an a fetch request to the following the url fetched.

await fetch(`${await getUrl()}/path/to/the/file?method=readFile`, {
  method: "GET",
  headers: {
    Authorization: `Bearer ${getToken}`
  }
});

The method param correspondents to the type of operation. For example mkdir is a POST.