https://github.com/danielrs/workers-outbound-poc
Proof-of-concept for safer fetches in Outbound Workers.
https://github.com/danielrs/workers-outbound-poc
Last synced: 9 months ago
JSON representation
Proof-of-concept for safer fetches in Outbound Workers.
- Host: GitHub
- URL: https://github.com/danielrs/workers-outbound-poc
- Owner: danielrs
- Created: 2024-10-28T14:46:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-28T15:06:27.000Z (over 1 year ago)
- Last Synced: 2025-04-12T06:59:46.551Z (about 1 year ago)
- Language: JavaScript
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Proof-of-concept for using the `global_fetch_strictly_public` flag in [Outbound Workers](https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/configuration/outbound-workers/).
The request flow is:
```
Eyeball -> Dispatcher -> Outbound -> User-worker (fetches from same zone the dispatcher is in)
```
## Requirements
- [Just](https://github.com/casey/just)
- [Node.js](https://nodejs.org/en/download/package-manager)
## Steps to set up
### 1. Zone configuration
We're gonna be using the zone `drivas.xyz` configured as follows:
- Origin Worker on `origin.drivas.xyz/foo` - Always returns `origin FOO`.
- Middleware Worker on `origin.drivas.xyz/foo` - Just wraps the request to the origin.
- AAAA route on `outbound-poc-dispatcher.drivas.xyz` - Make sure our dispatcher is reachable, content is `100::`.
### 2. Make necessary edits
If you're using a different zone, it might be necessary to edit the following files:
- `outbound-poc-dispatcher/src/wrangler.toml` - Route to your own zone.
- `outbound-poc-user-free/src/index.js` - Fetch from your own zone.
- `outbound-poc-user-premium/src/index.js` - Fetch from your own zone.
### 3. Deploy
First time:
```
just -v init
```
After that:
```
just -v deploy-all
```
### 4. Visit dispatcher
Free user should behave as any other eyeball request:
https://outbound-poc-dispatcher.drivas.xyz/outbound-poc-user-free
Premium user goes directly to the origin:
https://outbound-poc-dispatcher.drivas.xyz/outbound-poc-user-premium