Guys how do I access env vars set via
Guys how do I access env vars set via
wrangler secret put <KEY>
setting it this way
throws ✘ [ERROR] ReferenceError: env is not defined
3 Replies
Hey @Zaddy , you need to make sure your Container class has access to
env
from the Workers script
If you add a secret with npx wrangler secret put MYSECRET
make sure to also add it to .dev.vars like MYSECRET="secret"
Then render Env in worker-configuration.d.ts with npx wrangler types
And do export class MyContainer extends Container<Env> {
Then will workUse this.env instead of just env
thank you