hiding open source worker env vars
if i want to make my worker open-source, but need to have secret environment variables, how would i go about setting them only in the web ui
1 Reply
Use Secrets
https://developers.cloudflare.com/workers/platform/environment-variables/#add-secrets-to-your-project
An example of a open source project using secrets:
https://github.com/Cherry/ShareX-R2-Cloudflare-Workers
(Edit: he is using Github Actions to do deployments, maybe not the best example, but it is as simple as them doing wrangler secret put for the required secrrets, and then just wrangler deploy)
You just tell the user during setup use
wrangler secret put secret
From the UI, when you add a secret, click the Encrypt button next to it.
(If you're doing local testing and using .dev.vars
, don't push that to the repo, of course)
Secrets are one of the things also not destroyed by doing a wrangler deploy, it won't override them or anything