Local dev:[wrangler:err] Error: Secret "<name>" not found
⛅️ wrangler 4.10.0
App:
await env.<name>.get()
Result:
How do I set local secrets?6 Replies
Cloudflare Docs
Environment variables · Cloudflare Workers docs
Environment variables are a type of binding that allow you to attach text strings or JSON values to your Worker
@NicoMarchildon did this work for you?
I put the variable in the
.dev.vars
but still get the Secret "<name>" not found
error.@Pekket I might be incorrect that it goes in .dev.vars. I was unaware of the new secret store at the time. I plan on migrating to secrets store so will update what I end up doing
I just migrated to secrets store. It works with --remote flag but I dont think you can use secrets defined in a local setup yet (like .dev.vars). I imagine it's coming because if you run
npx wrangler secrets-store store create local-test
you get ✘ [ERROR] Local secrets stores are automatically created for you on use. To create a Secrets Store on your account, use the --remote flag.
but if you run npx wrangler secrets-store store list
you get:
✘ [ERROR] This command is not supported in local mode. Use
wrangler <cmd> --remote to list Secrets Stores on your account.
Ok thanks, for me everything is working good remotely. Locally i get the error
Secret .. not found
. I guess we will have to wait for an update.I found a workaround. I have a boolean variable
DEV
so anytime I access a secret I just do:
and then put the secret in .dev.vars