How am I supposed to access secrets??

I'm supposed to put my secrets in a .dev.vars file or use wrangler for deployed workers but how am I supposed to access them from my worker? I can't find out how to do it anywhere
3 Replies
Hello, I’m Allie!
On the env object:
export default {
fetch(request, env, context) {
return new Response('Hello');
},
};
export default {
fetch(request, env, context) {
return new Response('Hello');
},
};
conhlee
conhleeOP17mo ago
Oh awesome! Thank you
nat20sFruitBat07Dad
Do we need to explicity bind them in the URL? I have tried both binding and NOT binding and either way the DATBASE_URL value I specified in my .dev.vars does not come through. Never mind. I figured it out. For others who may experience this issue please do as follows: 1. Use wrangler secrets put to write the secret to the Worker 2. create a .dev.vars file in the root of your PROJECT and put your secrets in there 2a. Make sure you do NOT check in the .dev.vars file into your git. Its just for local development 3. Add the variable to your CF Worker environment so you can reference it in your code 4. And this is what got me... Restart your project (npm run start)
Want results from more Discord servers?
Add your server