Accessing .dev.vars outside of context
I use CF Workers and Hono to create an API and to read the secret variables in the .dev.vars you have to go through the context (c) but I want to define my client for several globally because i need to use it in multiple routes, did you know how i can do it?
.dev.vars:
index.ts:
2 Replies
you can't access Cloudflare environment variables outside of the context
Instead, you can create a function, put this client into it, and pass the variables as parameters. That way, you can use that function in whatever route you want.
I set up a global variable and set the value to that variable