Skip to content

bizbudding/monetizationos-springwire-cloudflare-proxy

Repository files navigation

MonetizationOS logo

MonetizationOS Cloudflare Proxy

MonetizationOS powers monetization for human and bot users alike. Use this Cloudflare Worker to proxy your website and integrate MonetizationOS Surfaces, enabling seamless monetization experiences for sites served with static HTML.

This worker includes handling for both HTTP response modification and CSS-targeted Components for content modifications including: removal/truncation, displaying offerings, and custom messaging.

Read more about using MonetizationOS at docs.monetizationos.com.

Getting Started

Deploy to Cloudflare

Click deploy to Cloudflare to get started or fork this repo to customize it for your needs.

Required Variables

This worker requires the following environment variables to be set in your Cloudflare configuration:

  • MONETIZATION_OS_SECRET_KEY: Your MonetizationOS secret key. Get your secret key.
  • ORIGIN_URL: The origin URL for your proxied website.
  • SURFACE_SLUG: The slug for the MonetizationOS surface you want to target.
  • AUTHENTICATED_USER_JWT_COOKIE_NAME: Cookie name for authenticated user JWT sessions.
  • ANONYMOUS_SESSION_COOKIE_NAME: Cookie name for anonymous sessions.

Bindings should be set in your wrangler.jsonc, or a .dev.vars.local file when working locally.

Optional: headers sent to the origin

ORIGIN_REQUEST_HEADERS adds or overrides outgoing headers on every upstream fetch to ORIGIN_URL. Set it to a JSON object mapping header names to values. Leave it as {} when no extra headers are needed.

In wrangler.jsonc vars:

"ORIGIN_REQUEST_HEADERS": { "X-Api-Key": "secret", "X-Custom": "my-value" }

In the Cloudflare dashboard, the variable supports JSON input directly.

Commands

  • npm run dev — Start local development using Wrangler.
  • npm run deploy — Deploy the worker to Cloudflare.
  • npm test — Run tests with Vitest.
  • npm run cf-typegen — Generate Cloudflare type definitions.
  • npm run lint — Run lint checks with Biome.

Local Development

  1. Install dependencies:
    npm install
  2. Start the development server:
    npm run dev

Deployment

Deploy to Cloudflare with:

npm run deploy

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors