FluxGlow

Where can I host a board file?

Anywhere that serves the file over https, lets other websites read it, and does not cache it for long. A storage bucket, a public GitHub repository or a web server you already run will all do.

What the host has to do

The board file is read by the browser on your monitor, from a page on fluxglow.com. That puts three requirements on wherever the file lives:

  • https. Browsers will not let an https page read a plain http address.
  • Cross-site reads. The response must carry the header Access-Control-Allow-Origin: *, or name https://fluxglow.com in place of the star.
  • No long caching. Cache-Control: no-cache is the safe setting. A file cached for an hour is a board that is an hour old.

The choices

HostUpdates showNotes
Amazon S3, Google Cloud Storage, Cloudflare R2, Azure Blob StorageAt onceNeeds a CORS rule and public read on the file. Costs pennies, or nothing, for one small file.
A public GitHub repository, read at its raw addressWithin five minutesFree and needs no settings. See the GitHub Actions example.
GitHub PagesAfter the next Pages deployAllows cross-site reads as it comes. Suits a file that changes a few times a day.
A web server you already runAt onceTwo headers in the server's configuration.

Amazon S3

Give the bucket a CORS rule, once:

cors.json
{
  "CORSRules": [
    {
      "AllowedOrigins": ["https://fluxglow.com"],
      "AllowedMethods": ["GET"],
      "AllowedHeaders": ["*"]
    }
  ]
}
Terminal
aws s3api put-bucket-cors --bucket your-bucket --cors-configuration file://cors.json

Then upload the file whenever it changes:

Terminal
aws s3 cp board.json s3://your-bucket/board.json \
  --content-type application/json --cache-control no-cache

The file also has to be readable without signing in, which is set in the bucket's permissions. Its address is then https://your-bucket.s3.amazonaws.com/board.json.

Google Cloud Storage

cors.json
[
  {
    "origin": ["https://fluxglow.com"],
    "method": ["GET"],
    "responseHeader": ["Content-Type"],
    "maxAgeSeconds": 300
  }
]
Terminal
gcloud storage buckets update gs://your-bucket --cors-file=cors.json
gcloud storage cp board.json gs://your-bucket/board.json --cache-control=no-cache

With public read on the object, its address is https://storage.googleapis.com/your-bucket/board.json.

A public GitHub repository

Commit the file and read it at its raw address:

Address
https://raw.githubusercontent.com/OWNER/REPO/BRANCH/board.json

GitHub adds the cross-site header itself. It also caches each file for five minutes, which is fine for a nightly job and too slow for a deploy you are watching.

Your own web server

nginx
location = /board.json {
    add_header Access-Control-Allow-Origin "*";
    add_header Cache-Control "no-cache";
}
Caddyfile
example.com {
    root * /var/www/html
    file_server
    header /board.json {
        Access-Control-Allow-Origin "*"
        Cache-Control "no-cache"
    }
}

Check it before you hang the screen

Terminal
curl -sI -H "Origin: https://fluxglow.com" https://example.com/board.json

Look for access-control-allow-origin in what comes back. If it is missing, the board will say it can't reach the board file. Sending the Origin header matters, because some hosts only add the cross-site header when they are asked by a browser.

Anyone with the address can read it

The file is public by nature. Keep secrets out of it, and see what FluxGlow can and cannot see for hosting it inside your own network.

All questions