To hide our backend service hostname but expose the auto-generated API docs at the same time, Threadseeker uses Cloudflare Worker as a reverse proxy for the API docs. This repo provides you the worker soucre code we're using for doc.threadseeker.app.
- Display your OpenAPI document while hiding the real API hostnames
- Proxy the OpenAPI.json request indiviually
- Disallow bots to index by setting
/robots.txt
and injectingnoindex
into<head>
For the completed guide, visit Cloudflare Doc.
Create a new worker project:
npm create cloudflare@latest -- doc-proxy-worker
cd doc-proxy-worker
Copy worker.js
and paste the content into src/index.js
, and replace the API_HOST
with your real backend hostname.
npx wrangler dev
To deploy the local worker to your Cloudflare account:
npx wrangler deploy
Complete the login steps and your worker will be avaliable on cloud.