Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

[Deprecated] An online proxy configuration adaptation tool for Cloudflare worker.

License

Notifications You must be signed in to change notification settings

tbxark-arc/proxy-config-worker

Repository files navigation

⚠️ proxy-config-worker is deprecated, please migrate to proxy-render(https://github.com/TBXark/proxy-render)


Proxy config worker

An online proxy configuration adaptation tool for Cloudflare worker.

Demo: https://proxy-config.tbxark.workers.dev

Cloudflare worker Tutorials can be found here.

Further documentation for Wrangler can be found here.

Installation

Install from the command line:

npm install @tbxark/[email protected]

Install via package.json:

"@tbxark/proxy-config-worker": "1.0.9"

Example

1. init project

npm i @cloudflare/wrangler -g
mkdir your-worker-name
cd your-worker-name
wrangler init  your-worker-name --type webpack
npm init
npm install @tbxark/[email protected]

2. edit configuration

Fill in the configuration in wrangler.toml

account_id = "your-account-id"
vars = { DOMAIN = "your-worker-name.your-name.workers.dev" }

3. add hook

import Application from '@tbxark/proxy-config-worker/index'
import HookConfig from '@tbxark/proxy-config-worker/src/hook/config'

HookConfig.after = async (token, port, style, config) => {
  return config + '\n\n#Powered by tbxark'
}

addEventListener('fetch', event => {
  event.respondWith(Application.handleRequest(event.request))
})

addEventListener('scheduled', event => {
  event.waitUntil(Application.handleSchedule(event.scheduledTime))
})