Programmatically create Cloudflare Pages Site, and upload content
I am building a website builder for a specific niche. And I really like Cloudflare Pages. I am thinking that my website builder will generate the static files, HTML, CSS, JS and host them on Cloudflare Pages. The challenge here is how do I create a Site and upload content, all programmatically?
Reading through the docs, I am thinking that maybe I can use Wrangler.
My idea is to put the "publish" work on a Queue. Then the Queue will trigger a worker (not necessarily CF Worker). The worker will fetch and compile the files from the builder. Then it will use Wrangler to create the Site (if it is a new project) and upload the files.
Help me figure this out if this is feasible.
Oh yeah ... one more thing, I also need to be able to attach customer's custom domain to the Site too.
Account ID:
19e9ad6ebb3da377311bc155ecc15134
2 Replies
All sounds pretty reasonable to me!
You might want to actually do the publishing from within the builder, since you could presumably run Wrangler from within that environment (Wrangler won't run in a Worker), but the rest all sounds good!
I'll give it a go later. Thanks.