curtis
1
I have a worker with environments.
The API accounts/{account_identifier}/workers/scripts/{script_name} fetches the script by name. And in my case only downloads the from my production
environment.
How does one use the API to fetch a script from an alternate environment such as dev
?
curtis
3
Poking under the dash.cloudflare.com hood, I find this undocumented API that at least tells me I have multiple environments.
accounts/{account_identifier}/workers/services/{script_name}
{
"id": "www",
"default_environment": {
"environment": "production",
"script": {
"id": "www",
"logpush": false,
"handlers": [
"fetch"
],
"last_deployed_from": "dash",
"usage_model": "bundled"
}
},
"environments": [
{
"environment": "production",
},
{
"environment": "dev",
}
]
}
(*) Note, I pruned some fluff from that json for simplicity.
So it appears that accounts/{account_identifier}/workers/scripts/{script_name}
downloads the default_environment
script.
What’s the undocumented API to download the script for the alternate environments?
curtis
4
Aha! One more undocumented API ftw…
accounts/{account_identifier}/workers/services/{script_name}/environments/{worker_env}/content
Boom.