Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add JavaScript code to a Cloudflare Worker?

Cloudflare’s docs and blog posts clearly state they support JavaScript code in their Workers, but I can’t find any way to add JavaScript or access the editor?

Specifically I’m trying to build a maintenance page via their Workers API, following this (rather old) guide.

I’ve been looking for a half hour now and can’t find any way to add JS code to Workers for my life. Can anyone point me in the right direction?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you need to use a web editor, then you can use the Service environments
(Quick Edit) feature
. Just create a new service, then click the blue Quick Edit button under Worker in the Resources tab.

However, you should prefer to use the Wrangler CLI. With Wrangler, you create an NPM project on your local machine that can be pushed to Cloudflare workers when you’re ready to deploy. Wrangler also lets you test on your local machine. The Cloudflare Workers documentation guides you through using the Wrangler CLI in depth.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading