Skip to content

A template for a Cloudflare worker which serves as a production CDN for a Helix project.

License

Notifications You must be signed in to change notification settings

adobe/helix-cloudflare-prod-worker-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

helix-cloudflare-prod-worker-template

A template for a Cloudflare worker which serves as a production CDN for an AEM project.

src/index.mjs is the content of the Workers script.

1. Setup Cloudflare production site

Follow the instructions here.

2. Edit wrangler.toml

Update the following entries:

  • route (route for your site, e.g. *.mydomain.com/*)
  • zone_id (your Cloudflare Zone ID)
  • account_id (your Cloudflare Account ID)
  • ORIGIN_HOSTNAME (the hostname of your AEM project, e.g. main--mysite--hlxsites.aem.live)

You can find your account_id and zone_id in the right sidebar of your site's overview tab at https://dash.cloudflare.com (you may have to scroll down).

3. Configure push invalidation (optional)

If you have succesfully configured push invalidation for your project your worker should send the following opt-in header:

X-Push-Invalidation: enabled

All you have to do is set the PUSH_INVALIDATION environment variable in the Cloudflare dashboard to enabled or do the same via wrangler.

4. Enable Origin Authentication (optional)

If you have enabled Site Authentication for your project your worker should send the following header:

Authorization: token <token>

All you have to do is set the ORIGIN_AUTHENTICATION environment variable in the Cloudflare dashboard to the token you have configured in your AEM project or do the same via wrangler.

5. Publish your site

Install wrangler (if you haven't done so already):

npm i @cloudflare/wrangler -g

Publish your site:

wrangler publish

5. Test your site

Point your browser to your site (e.g. https://www.mydomain.com/).

For troubleshooting you can turn on logging in your terminal:

wrangler tail -f pretty

About

A template for a Cloudflare worker which serves as a production CDN for a Helix project.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published