Once you have created a Cloudflare Worker, you will need to assign that Worker to a route. In other words, Cloudflare needs to know where the script should intervene in the request between the user and the origin server.
Getting Started
To set this up, you will need to navigate to your domain in the Cloudflare Dashboard, click "Workers Routes" and then click "Add route":
Add a Route
Once you click "Add route," a popup will appear where you can add both the Route and the Worker that will be active on that route.
In this example, the Worker give-it-a-good-name
will run on all requests where the URL contains somestore.commercebuild.tools/admin
. In other words, if the URL is somestore.commercebuild.tools/admin
or somestore.commercebuild.tools/admin/someotherpage
, this worker will execute.
Once you've completed these settings, be sure to click "Save."
Testing your Route and Worker
The final step is to make sure your Worker is executing. On your Worker admin page, Cloudflare provides logs and statistics that will help you determine how it's performing:
If you have more questions, please contact Cloudflare Support or refer to their documentation.