Before you start
Create a Worker project. Then install@waniwani/relay 0.6.0 or later:
Steps
1
Write src/index.ts
src/index.ts
if block at the top of its fetch handler.2
Write wrangler.jsonc
Put your hostname in place of
example.com:wrangler.jsonc
3
Add the key and deploy
In the Worker folder, run these commands. When the first command asks for the key, paste the key from the setup screen.
4
Check
In the setup screen, enter the address of one of your pages and click Check now.
With agent pages or blocking
When the website serves agent pages or blocks an agent, the setup screen gives you thissrc/index.ts. It also calls serveAgentPage:
src/index.ts
export default to the top of its file. Then add each line of the fetch handler, except return fetch(request), at the top of its fetch handler.
You make this change one time. After it, you turn agent pages and blocking on and off in the dashboard, with no deploy.
Notes
waitUntilkeeps the event alive after the response. Thus, the agent does not wait for it.- With Only some paths, the routes have your paths, and the Worker checks each path again with
isChosenPage. A route can only end in*. Thus,/pricing*also matches/pricing-old. Also add the paths of your agent pages. - In the EU region, each call gets
region: "eu".