Cloudflare Worker
This document describes integrating with the Spec Platform through a Cloudflare worker.
Last updated
This document describes integrating with the Spec Platform through a Cloudflare worker.
Last updated
Please review the following and ensure that that your development environment has the relevant dependencies installed with the latest version:
Follow Cloudflare’s “Get started guide” to install Wrangler in your development environment.
This is the Cloudflare Workers command-line interface, which allows you to create, edit, and publish Workers projects to your Cloudflare account.
Following installation, authenticate wrangler.
The Spec Worker Library for Cloudflare
Check out the configuration options for the Spec Platform in .
Configure a new project with Wrangler, or open an existing project.
Install NPM Spec Proxy Cloudflare Worker into project:
npm i –save @specprotected/spec-proxy-cloudflare-worker
Open src/index.ts
and copy the Spec Worker Library code from the Prerequisites.
Publish the worker. Open a terminal window and run wrangler deploy
With the worker published, we can now use the Cloudflare admin console to configure a route that will use the Spec Worker code.
Click "Workers & Pages" from the Cloudflare sidebar
Select the newly published worker and navigate to "Settings".
Next to "Domains and Routes", click "Add" to add a new route for the worker.
Select "Custom domain" or "Route" and fill out the relevant fields
Confirm your changes by clicking "Add domain" or "Add route"
The Spec Cloudflare Worker is now live!
If no existing workers exist, the following is Spec's recommended worker code. If there are existing workers, Spec's Product Success will assist in merging the following code with your existing code.
Check Edge Workers page for configuration options.