This is a lightweight content relay station project based on Cloudflare Workers and KV, ideal for developers who need a simple and efficient solution for content storage. It does not rely on R2 buckets, is easy to deploy, and is suitable for small-scale projects.
This project is extracted from a historical version of the original project as I found it useful. It is open-sourced under the original project's license. If there are any infringement issues, please contact me for removal.
Original project repository: Pastebin Worker - Historical Version
- Log in to Cloudflare Dashboard.
- Click on your profile icon in the top-right corner and select My Profile.
- Go to the API Tokens page.
- Click
Create Tokenand choose theEdit Cloudflare Workerstemplate. - Configure and create the token, then copy the generated API Token.
- Log in to Cloudflare Dashboard.
- Click on Storage & Database in the left menu and select
KV. - Create two
KVnamespaces namedPBandPBIMGS. - Save the
IDsfor later use.
- Open your project repository on GitHub.
- Navigate to Settings > Secrets and variables > Actions.
- Click
New repository secret. - Set the name as
CF_API_TOKENand the value as your generated API Token.
- Set the frontend environment variables in
./static/.env:VITE_API_BASE_URL=<Your Cloudflare Worker Deployment URL>
- Ensure this URL is added to Cloudflare DNS, as it will be automatically resolved.
- Update the following variables in
./wrangler.toml:
- Every push to the
mainbranch will automatically trigger the deployment workflow via GitHub Actions. - To manually trigger a deployment:
- Open the GitHub Actions page.
- Find the appropriate Action and click
Run workflow.
- Log in to Cloudflare Dashboard.
- Create two KV namespaces:
- One for storing files (named
PBIMG). - One for storing text (named
PB).
- One for storing files (named
- Save their
IDsfor later use.
name = "pastebin-worker"
compatibility_date = "2023-11-28"
account_id = "<Your account_id>"
main = "src/index.ts"
workers_dev = false
vars = { ENVIRONMENT = "production" }
route = { pattern = "<Your Domain>", custom_domain = true }
kv_namespaces = [
{ binding = "PB", id = "<PB kv id>" },
{ binding = "PBIMGS", id = "<PBIMG kv id>" }
]
[site]
bucket = "./static/dist"account_idcan be found in your Cloudflare Dashboard profile.- If you are not using a custom domain, comment out the
routeline.
npm i @cloudflare/wrangler -g
wrangler login
wrangler devcd static
yarn install
yarn devAfter starting:
- Backend address:
http://localhost:8787 - Frontend address:
http://localhost:5173
Run the following in the static directory:
yarn buildAccess http://localhost:8787 to view the built frontend.
-
Install Wrangler CLI:
npm i @cloudflare/wrangler -g
-
Log in to your Cloudflare account:
wrangler login
-
Verify login:
wrangler whoami
Your username should appear if the login is successful.
yarn installcd static
yarn installRefer to Deployment Documentation for setting up wrangler.toml and .env files.
Follow the instructions in Start the Service to run the backend and frontend.
- Access
http://localhost:5173locally to test the frontend. - Backend API address:
http://localhost:8787.
Refer to Deployment Documentation.





