Your own sync server

Run your own sync server

Factwright’s sync server is open source, so you can run your own copy in a free Cloudflare account. Factwright and your phone sync through it, end-to-end encrypted, just as they do through ours. It takes about 15 minutes, and there’s no code to write.

Good to know first

  • Cloudflare may ask for a payment method before it turns on R2, its file storage, even on the free plan. R2 is free up to 10 GB of storage a month.
  • Updates to your server aren’t automatic yet. It keeps the version you deploy. More about updates
  • Connecting needs Factwright 0.9 or later, which has Connect your server… under Sync, for the last step here.
  1. Step 1: Your Cloudflare account

    In Cloudflare, open Workers & Pages (opens in a new tab). Your subdomain is next to Your subdomain: it’s the part before .workers.dev. If Cloudflare asks you to choose one first, any name will do.

    Your server’s address
    https://factwright-sync.yourname.workers.dev

    Put your subdomain in place of yourname, here and in the steps below.

    Then turn on R2, where your server keeps your locked files: open R2 (opens in a new tab) and follow Cloudflare’s steps to add it. That’s where Cloudflare may ask for a payment method.

  2. Step 2: A GitHub sign-in app

    Your server signs you in with GitHub, through a sign-in app of your own. Open GitHub’s page for a new OAuth app (opens in a new tab), and fill it in:

    Application name
    Factwright sync
    Homepage URL
    https://factwright-sync.yourname.workers.dev
    Authorization callback URL
    https://factwright-sync.yourname.workers.dev/api/auth/callback/github

    Leave the rest as it is, and click Register application. On your new app’s page, click Generate a new client secret. GitHub shows the secret only once, so keep that page open for the next step.

  3. Step 3: Deploy

    Click Deploy to Cloudflare, and sign in to Cloudflare and GitHub if it asks. It copies the server into a new repository in your GitHub account, makes its database and file storage, and deploys it.

    Deploy to Cloudflare (opens in a new tab)

    Keep the names it fills in. Your address and your GitHub app use the server’s name, factwright-sync. When it asks for the server’s secrets, paste in:

    BETTER_AUTH_SECRET
    Any random text of 32 characters or more, such as a password manager makes
    GITHUB_CLIENT_ID
    The Client ID on your GitHub app’s page
    GITHUB_CLIENT_SECRET
    The client secret you generated
    ALLOWED_GITHUB_USERS
    Your GitHub user name, so only you can sign in

    Then click Create and deploy. Once it’s done, open your server’s address to check it: it shows “Your job hunt, anywhere”, with Continue with GitHub.

  4. Step 4: Connect Factwright

    In Factwright, click Turn on… under Sync, then Connect your server…, and paste your server’s address:

    Your server’s address
    https://factwright-sync.yourname.workers.dev

    Sign in with GitHub, and Factwright walks you through the rest, as it does for its own sync. To add your phone or another computer, choose Link a phone or computer in Factwright’s Sync settings, as usual: your phone opens your job hunt from your own server.

    The browser extension can save through your server too, from its version 0.2: in its setup, choose Through sync, then Your own server.

Keeping it up to date

Updates to your own server aren’t automatic yet: it keeps running the version you deployed. Within hours of each Factwright release, its server is in factwright/sync-server, and a way for your copy to update itself from there is on the way. Until then, if you’d like a hand updating, ask on GitHub.

Questions

What does it cost?

Nothing within Cloudflare’s free plan, and a job hunt is small. Your server’s files go in R2, which is free up to 10 GB of storage a month. Past that, Cloudflare charges the payment method it asked for when it turned R2 on. List only your own GitHub account when you deploy, and no one else’s files add to it.

Would you rather not run a server?

Then use ours: Factwright’s sync has nothing to set up, for $5 a month or $50 a year.

Who can see my job hunt?

Only you. Factwright locks it on your computer before it leaves, with a key only you hold, so your server keeps it only in a form it can’t read, just as ours does. The server is yours alone: it reports nothing to us, and we can’t reach it.

Who can sign in to it?

Only the GitHub accounts you list in ALLOWED_GITHUB_USERS: yours, and anyone else’s you add after a comma. Anyone else is turned away with a note that the server is private. To change the list, open Workers & Pages in Cloudflare, then factwright-sync, then Settings. Edit it under Variables and Secrets, and click Deploy. Taking someone off stops them signing in again, though their devices stay signed in until they sign out.

If you leave it empty, anyone with a GitHub account and your server’s address can make an account on it, as anyone can on Factwright’s own. Each account is private, with its own keys, so no one can see anyone else’s job hunt. But each one’s files count toward your Cloudflare account’s free allowance, and R2 storage past it is charged to you.

Is it the same server Factwright runs?

Yes. Each release’s copy is built from Factwright’s own code, apps/server, with nothing changed. It leaves out what only Factwright’s own server needs: its address, its legal pages and its usage totals.

Can I use a domain of my own?

Yes. The server’s README says how, under Running your own.

Would you rather use a terminal?

The README in factwright/sync-server has the steps for deploying with Wrangler, Cloudflare’s command-line tool.

My server says signing in isn’t set up

It’s missing your GitHub app’s Client ID or secret. In Cloudflare, open Workers & Pages, then factwright-sync, then Settings. Under Variables and Secrets, add GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET as secrets, and click Deploy.

GitHub won’t sign me in

Check that your GitHub app’s Authorization callback URL is exactly the one in step 2, with your subdomain in it, and that its Client ID and secret are the ones you gave Cloudflare. If it says the server is private, check that ALLOWED_GITHUB_USERS has your GitHub user name, spelled as it is on GitHub.

Need help?

Ask on GitHub: open an issue in Factwright’s repository, and say it’s about your own server. Leave your secrets out of it.

Open an issue