workers-sdk
workers-sdk copied to clipboard
🚀 Feature Request: `wrangler pages create` accpets `custom-domain` as an argument
In the process of creating (or publishing) a project it would be great to be able to pass a custom domain url.
Context
Currently wrangler pages create <proj-name> will create CF Pages project <proj-name> available under url <proj-name>.pages.dev. In our CD pipeline we would like to publish this project directly to dev, prod or staging environment where assets would be available at <our.own.url>. With current limitation of wrangler2 this step needs to be done manually via UI.
What would I like to see happen
While setting up a project I would be able to add a configuration parameter describing custom domain for the project:
wrangler pages create <proj-name> --custom-domain="<our.own.url>"
As a consequence newly created project would come with Custom Domain set up (in CF Pages' nginx I guess). With a project set up that way I could create DNS CNAME entry our.own.domain -> proj-name.pages.dev and have assets available at https://our.own.url.
Considerations
The question here is if custom domains would become a whole new thing to manage. I can see how custom domains settings would have to become CRUD-capable. So maybe a limitation of one custom-domain per project would help?
Hey there! Thank you for the suggestion. This is a great idea. However, there is some nuance here:
Project creation and custom domain addition are currently two separate operations internally. This would imply that one of them could fail. Now if the project creation succeeded after calling wrangler pages create <proj-name> --custom-domain="<our.own.url>" but the domain addition did not for whatever reason (domain already taken, invalid domain etc), error handling would be complicated because the operation is not atomic and it wouldn't be immediately clear what we ought to roll back.
Now, instead we propose that we could add this as a separate command. Something like wrangler pages project <proj-name> domains create maybe? What do you think of this?
I can see how custom domains settings would have to become CRUD-capable. Exactly. We ought to then add
domains listas well since a project can have more than one.
Cc @nevikashah
This would be incredibly helpful. A final intended outcome of this feature request is being able to fully automatize process of publishing of pages. With wrangler pages project <proj-name> domains create I could achieve my goal. So yes for full CRUD it would have to be:
wrangler pages project <proj-name> domains --help
add <our.own.url>
remove <our.own.url>
list
@peeech even without wrangler support, you could curl the Cloudflare API to achieve the same. https://api.cloudflare.com/#pages-domains-add-domain
curl -X POST "https://api.cloudflare.com/client/v4/accounts/9a7806061c88ada191ed06f989cc3dac/pages/projects/this-is-my-project-01/domains" \
-H "X-Auth-Email: [email protected]" \
-H "Authorization: Bearer ..." \
--data '{"name":"example.com"}'
Hi @peeech! Thanks for flagging this. In an effort to remove stale issues so we can have better signal on current friction points, we’re closing out issues that have not been updated within the last 6 months. This is likely something that will become less of a problem as Workers and Pages converge. See https://blog.cloudflare.com/pages-and-workers-are-converging-into-one-experience/ for more details.