Try it
The Report a problem button at the corner of these pages is open.relay, used as it is meant to be. Press it and send something: it becomes a real issue on journey-to-code-org/open.relay.
Every issue it files carries the demo label and says in its body that it came from the docs demo, so none of them is a real bug report. They are closed in batches.
If the button is missing, the demo server is switched off, and the rest of the page is unaffected.
How it is put together#
- The button is
docs-site/widget/relay-widget.ts: about a hundred lines of plain DOM on top ofcreateRelayClientandcreateReportFlow. No framework, which also shows the flow controllers working outside React. - The server is
packages/docs-worker: a Cloudflare Worker aroundcreateRelay.createRelayspeaks plainRequestandResponse, so it runs there unchanged. The Worker adds the three things a docs site needs and an app does not: it labels every issuedemo, it answers CORS for the docs origin only, and it identifies people by Cloudflare'scf-connecting-ip. - The page loads the button through one
<script>tag indocs-site/openblog.json(snippets.bodyEnd). Itsdata-relayattribute is the Worker's address; empty, the button never appears.
Run your own#
Use this as a template for a relay on any static site.
- Create a fine-grained GitHub token limited to your repository, with Issues: read and write.
- In
packages/docs-worker, setREPOandALLOWED_ORIGINSinwrangler.toml. npx wrangler deploy, thennpx wrangler secret put GITHUB_TOKEN.- Put the Worker's address in the script tag's
data-relay.
The limits (three reports per person per ten minutes, twenty a day) are kept per Worker instance, so they are a floor and not a guarantee. If a public demo needs a hard limit, add a rate limiting rule in front of it.
Screenshots are left out of the demo on purpose: a screenshot of a documentation page adds nothing and needs storage the Worker does not have.