Figroll Documentation

An overview of our Figroll Documentation, from uploading your site to changing your DNS.

Proxied Requests

Proxied Requests allow you to transparently pass requests through Figroll on to your API server. Imagine that you have the following setup:

API Server: https://api.figroll.io
Website: https://app.figroll.io

It’s completely acceptable on your frontend to make requests to your API server

  • https://api.figroll.io in this case and you’d get valid JSON back.

But wouldn’t it look nicer if the URL was https://app.figroll.io/api. This way everything is under the same domain, meaning you don’t have to worry about CORS. Some other benefits include:

  • Filter requests before they hit your API server
  • Restricting API access only to Figroll IP addresses
  • You can self sign your API certificate, rather than getting one.

To set this up you need to include a figroll.json file in your document root, we’ll remove access to it after upload.

dist/
    js/
    css/
    images/
    index.html
    figroll.json

In your figroll.json file you should have something like this:

{
    "routes": {
        "/api(.+)": {
            "proxy_pass": {
                "default": "https://api.figroll.io$1"
            }
        }
    }
}

What does all of this mean?

{
    // Tell Figroll we have some Routes
    "routes": {

        // Match anything after /api
        // This is a regular expression of the URL Path to match
        // The following URL will match:
        //  => https://app.figroll.io/api/v1/sites/1
        //  => /api/v1/sites/1
        "/api(.+)": {

            // Proxy these requests
            "proxy_pass": {

                // Send them to this URL. Using the Regular
                // expression above take the match and put it in
                // the new URL
                // => /api/v1/sites/1
                // => /v1/sites/1
                // => https://api.figroll.io/v1/sites/1
                "default": "https://api.figroll.io$1"
            }
        }
    }
}

Note: Only 1 match group is supported

Note: The positioning of (.+) and $1 is really important.


Once you’ve added the file to your dist folder, upload your site as normal and your proxy settings will apply.